sql - Dynamic Update query in procedure -


i'm trying create dynamic update query column listed out in tables in db. however, query failing error code: -942 message: ora-00942: table or view not exist ora-06512: @ "mantas.p_jrsdcn_tr", line 14.

code:-

create or replace procedure p_jrsdcn_tr ( out_error_cd out number,        -- returns 0 if no error; else error out_error_msg out varchar2       -- returns empty string if no error; otherwise error , trace )authid current_user     counter  number(20) :=0;    cursor tab_col_cursor  select distinct owner||'.'||table_name table_name,column_name all_tab_cols table_name in ('kdd_review') , column_name='jrsdcn_cd';  begin        tab_col_rec  in tab_col_cursor      loop  execute immediate 'update tab_col_rec.table_name set tab_col_rec.column_name = p2||substr(tab_col_rec.column_name,3) substr(tab_col_rec.column_name,1,2)= pl';  counter := counter +sql%rowcount ;  if counter >= 50000      counter := 0;      --commit;     end if;  -- done!         out_error_cd := 0;     out_error_msg := '';     dbms_output.put_line('turkey jurisdiction update completed sucessfully @ ' || to_char(sysdate,'mm/dd/yyyy hh24:mi:ss'));         end loop; exception when others         rollback;         out_error_cd := sqlcode;         out_error_msg := substr(sqlerrm, 1, 200) || chr(10) || substr(dbms_utility.format_error_backtrace, 1, 3896);                 dbms_output.put_line('  code: ' || out_error_cd);         dbms_output.put_line('  message: ' || out_error_msg);         dbms_output.put_line('turkey jurisdiction update failed @ ' || to_char(sysdate,'mm/dd/yyyy hh24:mi:ss'));  end;  / 

appreciate on procedure.

there no table called tab_col_rec.table_name

you wanted this:

execute immediate 'update ' || tab_col_rec.table_name || ' set ' || tab_col_rec.column_name || ' = p2||substr(' || tab_col_rec.column_name ||',3) substr(' || tab_col_rec.column_name || ',1,2)= pl'; 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -