Execute Immediate with INTO and Count
505977Sep 29 2006 — edited Sep 29 2006It's Friday and maybe I can't think straight:
I have the following:
v_sql := 'Select Count(*) From ' || v_stable
|| ' Where object_type_cd=:object_cd'
|| ' and kpi_indicator_type_id=:type_id'
|| ' and security_reference_id=:ref_id';
execute immediate v_sql using 'KPI', v_type_id, v_camid into v_cnt;
if v_cnt > 0 then
<...do something here...>
end if;
v_sql is declared, v_stable is assigned, and my using variables are also assigned.
Should this work so that I can get the count in v_cnt? I'm having a hard time executing a test in TOAD so I'm not sure what I'm doing wrong.
This code is part of a procedure.
Thanks,
Greg