我有一个关于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));
显然,这是不行的,但是这将是实现这一目标的最佳途径,或者是它甚至可能吗?
感谢, 布赖恩