plsql - oracle dynamic sql using params with brackets as table name -
i have table in schema brackets in name (that's legacy, cannot modified):
create table "addresses" ("id" number(*,0) , "fulladdress" nvarchar2(100), "homenum" nvarchar2(25), "streetname" nvarchar2(50) )
so want have ability update table via dynamic sql. that's how attempt that:
declare sql_upd_statement varchar2(500) := ''; table_name varchar2(20) := '"addresses"'; column_name varchar2(20) := '"fulladdress"'; begin --no rows updated, sample sql_upd_statement := 'update stm.:1 set :2 = substr( :2, 2 ) :2 not null , :2 null'; dbms_output.put_line( sql_upd_statement ); execute immediate sql_upd_statement using in table_name, column_name; end;
please, tell me, possible reach want via dynamic sql? tried set 'table_name', 'column_name' values without brackets - still no luck.
schema object names cannot passed using bind variables, need literals.
sql_upd_statement := 'update stm.'||table_name||' set '||column_name||' = substr( '||column_name||', 2 ) '||column_name||' not null , '||column_name||' null';
Comments
Post a Comment