I'm doing collection of two columns(col & val). Into second select col is parameter of other columns and val is value of this column.
declare
TYPE t_my_list is record(id varchar2(1000), col VARCHAR2(4000),val VARCHAR2(4000));
TYPE list_3STR is table of t_my_list;
v_stmt VARCHAR2(32000) := 'SELECT id, col, val FROM userA.tableA';
v_lstmt VARCHAR2(32000);
v_ret list_3STR := list_3STR();
cDel number;
begin
EXECUTE IMMEDIATE v_stmt BULK COLLECT INTO v_ret;
for i in v_ret.first..v_ret.last loop
v_lstmt := 'SELECT count(*) FROM userB.tableB
WHERE NVL('||v_ret (i).col||', ''<null>'') in ('''||v_ret (i).val||''', ''<null>'') and idB = '''||v_ret (i).id||'''';
EXECUTE IMMEDIATE v_lstmt INTO cDel;
If cDel > 0 Then
--some code
cDel = 0;
end if;
end loop;
end;
But into my select statement I can have null so I'm using NVL. Also, as I can have number so I need to use convert to_char('||v_ret (i).col||')
. Also, type of column is number, RAW, date etc..
My question:
is other posibility then NVL?
if not, has oracle default converter? (all types need to be Varchar2)
val
? - Alex Poole