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

Code a dynamic query in a stored procedure.


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

New User


Joined: 14 Sep 2005
Posts: 74
Location: Atlanta, (USA)

PostPosted: Fri Jun 15, 2007 1:29 am
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
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 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 RC query -Time column CA Products 3
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts Dynamically pass table name to a sele... DB2 2
Search our Forums:

Back to Top