IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

how to resolve sql code=-313 abend?


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
babu_hi

New User


Joined: 11 Apr 2006
Posts: 93

PostPosted: Wed Aug 27, 2008 4:22 pm
Reply with quote

I am implementing dynemic sql cursor in my interface program.If the source program return one table name then the this interface program is working fine.but if the source program return more than one table name then i am getting -313 sql code.

let me explan clearly,Earlier we have one huge table,as per the new requirement they created meny tables under the same schema.

In the dynemic sql the query will be looks like this,

(SELECT * FROM TABLENAME1
WHERE SEND_RT_NO = ?
AND RECV_RT_NO = ?
AND RESEND_IND = ?
AND FILE_RECV_CNT = ?
AND CREA_DTE = ?
AND CREA_TME = ?
AND CASH_LET_BUS_DTE = ?
AND CASH_LET_ID = ?
AND BUNDLE_ID = ?
AND CNTL_REC_IND = ?)

UNION

(SELECT * FROM TABLENAME2
WHERE SEND_RT_NO = ?
AND RECV_RT_NO = ?
AND RESEND_IND = ?
AND FILE_RECV_CNT = ?
AND CREA_DTE = ?
AND CREA_TME = ?
AND CASH_LET_BUS_DTE = ?
AND CASH_LET_ID = ?
AND BUNDLE_ID = ?
AND CNTL_REC_IND = ?)


EXEC SQL

OPEN ARW_X9_CURSOR USING :WS-DBL-SEND-ABA,
:WS-DBL-RECV-ABA,
:WS-DBL-RESEND-IND,
:WS-DBL-FILE-RECV-IND,
:WS-DBL-CREATE-DATE,
:WS-DBL-CREATE-TIME,
:WS-DBL-BUSINESS-DATE,
:WS-DBL-CASH-LET-ID,
:WS-DBL-BUNDLE-ID,
:WS-DBL-HEADER

END-EXEC.

If the query contain more than one table i am getting -313 error,but i saw the reason for -313

SQL Code -313
THE NUMBER OF HOST VARIABLES SPECIFIED IS NOT EQUAL TO THE NUMBER OF PARAMETER MARKERS
Explanation: The number of host variables specified in the EXECUTE or OPEN statement is not the same as the number of parameter markers (question marks) appearing in the prepared SQL statement.

System Action: The statement cannot be executed.

Programmer Response: Correct the application program so that the number of host variables specified in the EXECUTE or OPEN statement is the same as the number of parameter markers appearing in the prepared SQL statement.

SQLSTATE: 53017

But the number of host variables specified in the OPEN statement is equal as the number of parameter markers (question marks) appearing in the prepared SQL statement.Even i am getting -313 abend,please let me know why i am getting this abend and how to resolve this?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Aug 27, 2008 5:12 pm
Reply with quote

Try this:

Code:

OPEN ARW_X9_CURSOR USING :WS-DBL-SEND-ABA,
:WS-DBL-RECV-ABA,
:WS-DBL-RESEND-IND,
:WS-DBL-FILE-RECV-IND,
:WS-DBL-CREATE-DATE,
:WS-DBL-CREATE-TIME,
:WS-DBL-BUSINESS-DATE,
:WS-DBL-CASH-LET-ID,
:WS-DBL-BUNDLE-ID,
:WS-DBL-HEADER,
:WS-DBL-SEND-ABA,
:WS-DBL-RECV-ABA,
:WS-DBL-RESEND-IND,
:WS-DBL-FILE-RECV-IND,
:WS-DBL-CREATE-DATE,
:WS-DBL-CREATE-TIME,
:WS-DBL-BUSINESS-DATE,
:WS-DBL-CASH-LET-ID,
:WS-DBL-BUNDLE-ID,
:WS-DBL-HEADER
Back to top
View user's profile Send private message
babu_hi

New User


Joined: 11 Apr 2006
Posts: 93

PostPosted: Thu Aug 28, 2008 10:39 am
Reply with quote

Thanks Dick Brenholtz...It is working now.
But i don't know how meny tables return from source pgm to this interface pgm bcz no of tables depends on user input.

So how can i handle OPEN condition in my pgm?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 28, 2008 11:14 am
Reply with quote

babu_hi,

i just guessed based on the counts of markers in your sql and the info given in the -313 writeup.

That my suggestion is a solution leads me to believe that you would build the OPEN dynamically as you do the SELECT.
For every additional table, you would need an additional set of host variables in the OPEN.

Keep in mind, because you can visually see that they are repeated (the same for each set)
does not mean that DB2 will recognize that they are the same
or even attempt to make such a resolution.
Your sql could very well have different host variables for each of the different union segments.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts ISAM and abend S03B JCL & VSAM 10
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts VSAM return code 23 - for a Random read COBOL Programming 4
Search our Forums:

Back to Top