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
 

 

Code a dynamic query in a stored procedure.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
muffirulz

New User


Joined: 14 Sep 2005
Posts: 74
Location: Kentucky, USA

PostPosted: Fri Jun 15, 2007 1:29 am    Post subject: Code a dynamic query in a stored procedure.
Reply with quote

Hi,
I would like to know if we can code a dymanic select query in Stored proceudres. I have a requirement to have a query that has 7 variables in its where clause in which n3 are fixed and the other 4 are not fixed, ie they may or may not be populated. Inside the stored procedure at run time I would like to build query which will only contain the variables in where clause that are populated omitting the other ones.

Please can anyone help me out with this.

Thanks,
Back to top
View user's profile Send private message

trevor_rebelo

New User


Joined: 18 Aug 2005
Posts: 17

PostPosted: Fri Jun 15, 2007 6:53 pm    Post subject:
Reply with quote

Hi,


Check the variables and accordingly prepare the SQL text dynamically in the SP.
then prepare and execute the query.

just the way you write dynamic SQL.


Regards

Trevor
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 How to Capture the Max return code of... anilkumar922 All Other Mainframe Topics 0 Thu Jan 12, 2017 12:02 pm
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
This topic is locked: you cannot edit posts or make replies. Calling REXX code from ISPF panel sanchita dey TSO/ISPF 4 Mon Jan 02, 2017 5:13 pm
No new posts REXX DB2: Dynamic allocation of DB2.D... BHAS CLIST & REXX 3 Mon Dec 19, 2016 8:26 pm


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