MySQL Forums
Forum List  »  Stored Procedures

Dynamic SQL. Is it possible?
Posted by: Peter Hamilton-Scott
Date: November 04, 2005 01:40AM

I need to write an update SP that will take three (optionally nullable) parameters. The concept of nullable means I would not need to update the column affected by it. So, a call like CALL UPDATER(1, null, 3) would require an update to say, col1 and col3, but no change to col2. Using the concept of dynamic SQL that I've worked with in DB2 I could, based on the parameters I'm given, build a varchar string containing the runtime SQL to be executed. Something on the lines of:

UPDATE TABLEX SET COL1=PAR1, COL3=PAR3...
...or...
UPDATE TABLEX SET COL2=PAR2, COL3=PAR3...

If I create this varchar string then is it possible to run it as SQL?

I don't know if that is possible, but any advice will be appreciated.

Thanks.

Options: ReplyQuote


Subject
Views
Written By
Posted
Dynamic SQL. Is it possible?
3460
November 04, 2005 01:40AM
2641
November 04, 2005 03:51AM
2669
November 04, 2005 08:51AM
2398
November 23, 2005 10:50AM
2347
November 23, 2005 02:18PM
2427
November 04, 2005 08:54AM
6603
November 04, 2005 03:40PM
2462
November 04, 2005 05:21PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.