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

-311 in dynamic SQl using PREPARE


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

New User


Joined: 12 Nov 2007
Posts: 38
Location: Texas, USA

PostPosted: Wed Jun 01, 2011 10:01 am
Reply with quote

Hi,
I am writing a stored procedure that will have a dynamic query. SELECT, FROM and WHERE part of query are static whereas ORDER BY part is dynamic.

PREPARE S1 FROM :STMT

When I execute the SP it abends with SQLCODE -311 (THE LENGTH OF INPUT HOST VARIABLE NUMBER position-number IS NEGATIVE OR GREATER THAN THE MAXIMUM)

I need to give 74 columns in SELECT and approximate length of query (moved to STMT) becomes 1500 characters.

Please suggest a solution.

Regards,
Satish
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Jun 01, 2011 10:26 am
Reply with quote

Quote:
THE LENGTH OF INPUT HOST VARIABLE NUMBER position-number IS NEGATIVE OR GREATER THAN THE MAXIMUM)


1500 bytes for an sql is nowhere near the limit and has nothing to do with your problem

position number provides you with the position of the host variable that is incorrectly defined.

also, search the db2 threads, there have been several -311 discussions.
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 Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts JCL Dynamic System Symbols JCL & VSAM 3
No new posts Synctool-dynamic split job for varyin... JCL & VSAM 7
No new posts Dynamic file allocation using JCL JCL & VSAM 8
No new posts Dynamic Sortin DD cards SYNCSORT 8
Search our Forums:

Back to Top