Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> how to update a list of tables using native dynamic sql?
Hi all,
Given is the list of tables that need to be updated. I try to use this syntax (and many others) but got errors:
declare
sql_string1 varchar2(2000);
sql_string2 varchar2(2000);
tab varchar2(50);
begin
sql_string1 := 'update ';
sql_string2 := 'set created_date = SYSDATE,
created_userid = ''sale'', last_modified_date = SYSDATE, last_modified_userid = ''sale'' ;'; for tab in (select
'tablea',
'tableb',
'tablec',
'tabled'
from dual) loop execute immediate sql_string1 || tab || sql_string2; dbms_output.put_line( 'Updated -> ' || tab ); end loop;
I also tried:
declare
execute immediate sql_string;
dbms_output.put_line( 'Updated -> ' || tables(i) );
end loop;
exception
when others then
RAISE; -- raise_application_error( -20199, 'Error updating table: '|| tables(i) || ' (' ||SQLERRM || ')' ); end;
I get error:
declare
*
ERROR at line 1:
ORA-00911: invalid character
ORA-06512: at line 149
Received on Wed Apr 20 2005 - 14:18:46 CDT
![]() |
![]() |