Update statements with Execute Immediate
ProhanDec 2 2009 — edited Dec 30 2009You 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