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 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
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts Dynamic split of files under groups sril.krishy DFSORT/ICETOOL 4 Mon Apr 17, 2017 1:09 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm


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