DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: dynamic pl/sql procedure

  1. #1
    Join Date
    Oct 2001
    Location
    Purdue University
    Posts
    2

    Question

    I have about 110 tables in a database that all contain a column named session_id. All of the tables start with ETL_. I need to write a pl/sql procedure that will look at a special table, retrieve the max session_id and then update all of the etl_ tables with that session_id (if currenly null). Is there a way to do this with dynamic sql????

    Shannon

  2. #2
    Join Date
    Apr 2001
    Location
    UK
    Posts
    137
    Something like:

    declare
    cursor cu_tab_name is
    select table_name
    from user_tables
    where table_name like 'ETL%';
    begin
    -- read MAX session_id from special table
    for rec_tab in cu_tab_name loop
    execute immediate 'update '||rec_tab.table_name||
    ' set session_id = '||v_max_sess_id||'
    ' where session_Id is not null'
    end loop;
    end;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width