| Project name | SQLServerSPCall |
| Location | c:\tutorials\SQL |
| Framework | Choose the appropriate .NET Framework version from the drop-down list.
Note: Must be version 4.5 or later.
|
Because Visual Studio runs in 32-bit, and the connection you've created using SQL Server runs in 64-bit, you need to add a 32-bit solution platform before you can execute your stored procedure.
; then close the
Properties window.
You now code a COBOL program to call your stored procedure.
program-id. Program1 as "SQLServerSPCall.Program1".
data division.
working-storage section.
exec sql include sqlca end-exec.
01 empid PIC X(6). *>string.
01 lastname PIC X(50). *>string.
01 firstname PIC X(50). *>string.
01 connectString string.
01 spReturnCode binary-long.
procedure division.
exec sql connect to "LookupEMP" end-exec
if sqlcode <> 0
display "CONNECT FAILED"
end-if
set empid to "000020"
exec sql
:spReturnCode = call "LookupEMP" (:empid INOUT, :lastname OUT, :firstname OUT)
end-exec
if sqlcode <> 0
display "Call FAILED"
else
display "User = " firstname " " lastname
end-if
exec sql disconnect all end-exec.
goback.
end program Program1.
to save
Program1.cbl.
User = THOMPSON MICHAEL