Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

how to resolve sql code=-313 abend?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: how to resolve sql code=-313 abend?
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: 6968
Location: porcelain throne

PostPosted: Wed Aug 27, 2008 5:12 pm    Post subject:
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    Post subject:
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: 6968
Location: porcelain throne

PostPosted: Thu Aug 28, 2008 11:14 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts UNIT=AFF for Easytrieve code gandikk JCL & VSAM 7 Wed Jul 12, 2017 11:42 pm
No new posts C03 ABEND sjiraga PL/I & Assembler 1 Thu Jun 01, 2017 4:51 pm
No new posts DB2 Program abending without giving a... rahulgarg14 DB2 7 Mon May 29, 2017 8:10 pm
No new posts Job failing with USER = 4093 REASON C... Pradeepa S ABENDS & Debugging 1 Wed May 17, 2017 3:35 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us