Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Update statements with Execute Immediate

ProhanDec 2 2009 — edited Dec 30 2009
You don't seem to be able to execute an Update statement with multiple clauses when you use Dynamic SQL.
E.g., I tried this but it did not work:

v_ddl_string := 'UPDATE descript_temp
SET year = year + 1,
pybegin = add_months(pybegin, 12),
pyend = add_months(pyend, 12),
fdes = REPLACE(fdes, ' || v_max_year || ', ' || v_next_year || ')';

-- Update several columns in descript_temp.
EXECUTE IMMEDIATE v_ddl_string;


But I was able to execute the parts by doing them one at a time. E.g., this worked:

v_ddl_string := 'UPDATE descript_temp
SET year = year + 1';

-- Update several columns in descript_temp.
EXECUTE IMMEDIATE v_ddl_string;

And so did this:

v_ddl_string := 'UPDATE descript_temp
SET pybegin = add_months(pybegin, 12)';

-- Update several columns in descript_temp.
EXECUTE IMMEDIATE v_ddl_string;

Does anybody know the problem here?


Here is my banner:

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 27 2010
Added on Dec 2 2009
18 comments
9,364 views