我有一個關於Oracle中存儲過程的問題。 下面是存儲過程和表,因爲它代表:執行存儲在過程參數中的sql語句
create table STORES
(
ID number,
NAME varchar2(100),
CITY varchar2(100),
EXPIRES DATE
)
insert into stores values(1, 'Store 1', 'City 1', sysdate);
insert into stores values(2, 'Store 2', 'City 1', sysdate);
insert into stores values(3, 'Store 3', 'City 2', sysdate);
create table CLOSED
(
ID number,
NAME varchar2(100),
CITY varchar2(100)
)
create or replace PROCEDURE
pr_TestProc(subQuery IN VARCHAR2)
IS
begin
insert into CLOSED (ID, NAME, CITY)
select ID, NAME, CITY
from STORES
where ID in (1, 2, 3);
end;
我想什麼做的是傳過來的參數子查詢替換「在」值。 所以,如果我喜歡運行的程序:
execute pr_TestProc('select ID from STORES where EXPIRES <= sysdate');
傳遞的查詢應執行的過程中正在運行的子查詢。 喜歡的東西:
insert into CLOSED (ID, NAME, CITY) select ID, NAME, CITY
from STORES
where ID in (execute(subQuery));
顯然,這是不行的,但是這將是實現這一目標的最佳途徑,或者是它甚至可能嗎?
感謝, 布賴恩