If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Stored Procedures with Dynamic Select's Update's and Delete's

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-01-04, 09:50
mdfa mdfa is offline
Registered User
 
Join Date: Jun 2004
Posts: 3
Stored Procedures with Dynamic Select's Update's and Delete's

Hi,

All examples i have seen about dynamic sql within stored procedures, isn't actually dynamic sql, its more like late binding since they pass arguments to look for...

What im looking for is something like passing the columns has arguments...
For example...
SELECT :Column1 :Column2 etc etc
FROM :Table


How can i accomplish that in PL/SQL Stored Procedures or Java Stored Procedures.

Thx a lot.
Best regards,
Mauro Farracha
Reply With Quote
  #2 (permalink)  
Old 07-02-04, 09:26
dmmac dmmac is offline
Registered User
 
Join Date: Aug 2003
Location: Massachusetts, USA
Posts: 106
Refer to IBM documentation about cursors to process result set but to get you started:
DECLARE v_sql varchar(1000);
DECLARE v_dynamic statement;

SET v_sql = 'SELECT ' || column1 || ', ' || column 2 || ' FROM sometable WHERE ....'
PREPARE v_dynamic FROM v_sql;
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On