好吧,基本上我需要從一列中選擇多個ID,然後使用這些ID從表中刪除。試圖從一個SELECT中存儲多個值以便在DELETE中使用
目前我正在嘗試做這樣的事情,但我不確定自己是否做錯了事,甚至在正確的場地上。
--this will return multiple rows
select user_group_user_id, user_group_id
bulk collect into USERGROUPUSERID, USERGROUPID
from user_group_user_tab
where user_id = USERID; --USERID is argument passed in
--Attemting to delete multiple rows where the above results are found
delete from user_group_user_tab
where user_group_user_id in USERGROUPUSERID;
delete from user_group_tab
where user_group_id in USERGROUPID;
這是Oracle(11g)中存儲過程的所有部分。 USERGROUPUSERID和USERGROUPID在之前聲明。
任何人都有如何做到這一點的建議?我不確定是否需要批量收集,或者是否有完全不同的方法,或者我只是錯了。
謝謝!
簡單和重點,它的伎倆。 SQL不是我的強項,但我覺得我應該知道這一點。謝謝! – Brian 2012-02-28 16:54:27