Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
Former Member Absent Member.
Absent Member.
421 views

[archive] Problem with executing stored procedure

[Migrated content. Thread originally posted on 09 May 2008]

Hi,
I am using acusql 7.20 and i want to execute a stored procedure in my cobol program. When i do this the open cursor gives the next error "Attempt to execute nonexistent, unprepared or invalid statement spcurs"
I can't find what i'm doing wrong. Maybe somebody else can?
I use the next small program to test

IDENTIFICATION DIVISION.
PROGRAM-ID. magweg.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
COPY "SPECIAL.ENV".
INPUT-OUTPUT SECTION.
FILE-CONTROL.
DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
COPY "STANDARD.WS".
COPY "STANDSUB.WS".
01 num-rows-read PIC 9(09).
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 num-rows pic 9(09).
01 ret-code pic 9(09).
01 A24-NAAM PIC X(0030).
01 A24-VOORLETTERS PIC X(0005).
EXEC SQL END DECLARE SECTION END-EXEC.
COPY "SQL.WS".
COPY "DBLOGIN.LNK".
PROCEDURE DIVISION.
R00-HOOFD.
move "***********" to ws-dblogin-server.
MOVE "**" TO ws-DBLOGIN-USER.
MOVE "******" TO ws-DBLOGIN-PASSWORD.
EXEC SQL
CONNECT TO :ws-DBLOGIN-SERVER
USER :ws-DBLOGIN-USER
USING :ws-DBLOGIN-PASSWORD
END-EXEC.
display "Enter the name to search for: ", no.
accept A24-NAAM.
EXEC SQL declare spcursor cursor for
exec :ret-code = sp_listcustomer :A24-NAAM
END-EXEC.
EXEC SQL
open spcursor
END-EXEC.
perform until SQLCODE not = 0
EXEC SQL
FETCH spcursor into
:A24-NAAM, :A24-VOORLETTERS
END-EXEC
if SQLCODE = 0
add 1 to num-rows-read
display A24-NAAM, ", ", A24-VOORLETTERS
end-if
end-perform.
if num-rows not = num-rows-read
display "stored procedure error, " num-rows,
" not = ", num-rows-read
end-if.
R00-99.
GOBACK.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.