View previous topic :: View next topic
|
Author |
Message |
David Joyce
New User
Joined: 08 Aug 2008 Posts: 17 Location: Boulder Colorado
|
|
|
|
I am trying to write a DB2/Cobol program using the SQLDA that executes dynamic SQL with a fixed-list of SELECT columns but a variable list of paramater markers. I keep receiving a -313 on the OPEN CURSOR and am stumped as to why this is happening. We are running DB2 v8 and IBM Cobol 3.3.
After each SQL statement I do check the SQLCODE and stop the program if anything other than 0 is found.
Here is a basic structure of my program:
SQL statement
SELECT COL1,COL2 FROM TABLE1 WHERE COL3 = ?
Move the SQL statement to a ws-variable
EXEC SQL
DECLARE STMT STATEMENT
END-EXEC
EXEC SQL
DECLARE ACMCUR CURSOR FOR STMT
END-EXEC
move 5 to SQLN
EXEC SQL
PREPARE STMT INTO :SQLDA FROM :STMTBUF
END-EXEC
SET SQLDATA(1) TO ADDRESS OF COL1
SET SQLDATA(1) TO ADDRESS OF COL2
*** FOR EACH PARAMETER MARKER
*** SET VALUES IN SQLDA
MOVE 453 TO SQLTYPE(3)
MOVE 4 TO SQLLEN(3)
MOVE 'ACT ' TO COL3
SET SQLDATA(3) TO ADDRESS OF COL3
The OPEN fails with a -313
EXEC SQL
OPEN ACMCUR USING DESCRIPTOR :SQLDA
END-EXEC
Any help, suggestions would be greatly appreciated. Thanks. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Sqlcode -313 THE NUMBER OF HOST VARIABLES SPECIFIED IS NOT EQUAL TO THE NUMBER OF PARAMETER MARKERS
Redbook Dynamic SQL |
|
Back to top |
|
|
David Joyce
New User
Joined: 08 Aug 2008 Posts: 17 Location: Boulder Colorado
|
|
|
|
Dick,
Thanks for your reply but I am familiar with a -313 sqlcode. What I am hoping is someone to look at my code and let me know if I have something in the code I shouldn't or I am missing something in the code. Thanks. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
Have you checked the value of STMTBUF at the time of the PREPARE? |
|
Back to top |
|
|
David Joyce
New User
Joined: 08 Aug 2008 Posts: 17 Location: Boulder Colorado
|
|
|
|
Yes. Here is the value of STMTBUF
SELECT COL1,COL2 FROM TABLE1 WHERE COL3 = ? |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
SET SQLDATA(1) TO ADDRESS OF COL1
SET SQLDATA(1) TO ADDRESS OF COL2 |
|
Back to top |
|
|
|