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 All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts DB2 Query to get the count of Unique ... DB2 2
No new posts IBM IMU Utility for Easytrieve Code t... IBM Tools 0
No new posts Any way to prevent dynamic allocation? DFSORT/ICETOOL 6
No new posts purge jobs with return code 0 and ret... JCL & VSAM 6
No new posts Excuting store procedure via JCL batch JCL & VSAM 1
Search our Forums:


Back to Top