fetch table name from a column for from clause

前端 未结 2 1846
无人及你
无人及你 2020-12-20 10:57

I have a view t with me which has a column for table name and another column which has where clause condition.

    id| name|table_in| where_clause

    1 | S         


        
2条回答
  •  -上瘾入骨i
    2020-12-20 11:03

    @Akshay,

    Please find the code below for your reference.

    Create or replace procedure create_cursor is
    l_statement varchar2(32767);
    cursor v_records is
      select * from t;
    begin
    for temp in v_records
    loop
      l_statement := 'INSERT INTO myTable (id, name) select '||temp.id||','
       ||temp.name|| ' from ' || temp.table1 
       || ' where ' || temp.where_clause;
    
      execute immediate l_statement;
      end loop;
    end;
    /
    

提交回复
热议问题