使用Oracle PL/SQL,如何使用多個值爲IN clause
填充bind variable :b3
? (此代碼是僅用於演示目的 - 它可能無法編譯,但它確實澄清問題如有需要)如何使用動態PL/SQL與IN子句中的值的字符串?
declare
type work_rec is record (
work_status varchar2(50),
work_cd varchar2(50));
type work_tab is table of work_rec index by pls_integer;
t_work_tab work_tab;
sql_stmt varchar2(400);
begin
select case
when status_desc like '%Employed%' then 'Employed'
else 'Unknown'
end as work_status
,case
when status_cd between '1' and '9' then '1,2,3,4'
else '0'
end as work_cd
bulk collect into t_work_tab
from employee_table;
for i in t_work_tab.first..t_work_tab.last
loop
sql_stmt := 'insert into employee_hist
select name,
employer
from tax_table
where employment_cd in (:b3)'; --< how to populate this with '1','2','3','4'
execute immediate sql_stmt using t_work_tab(i).work_cd;
commit;
end loop;
end;
/
這個問題已經回答了很多次 - HTTP:/ /tkyte.blogspot.com/2006/06/varying-in-lists.html – OldProgrammer
謝謝你的鏈接,但它不是我想要的。 :-) – tale852150