Can we use collection variable as a table in execute immediate select statement?

59 Views Asked by At

I have written below code.

Declare
  Type t1 is record (id, type)
  Type t2 is table of t1;
  V_val t2;
Begin
  Select a.id, a.type 
    bulk collect into v_val 
    from table1 a 
   where exits(select 1 from table2 b where a.column = b.column);..
.
.

Some code is written here. If .. And now I am trying to insert collection variable into 1 table using execute immediate. Eg.

Execute immediate 'insert into ' || table || v_column_string ||  ' from' || table|| q'where type =1 and  flag =:1...

this is the main statement. Now I want to concatenate this insert state using my collection variable above something like below

Execute immediate 'insert into ' || table || v_column_string ||  ' from' || table|| q'where  flag =:1 and exists ( select 1 from table(v_val)y where y.id = id and y.type = type)

Using another variable.

Can anyone help me with this? Tried all the way but no luck... I am new to plsql coding. It will be great help .

0

There are 0 best solutions below