将SQL语句作为参数传到存储过程,请参见一下示例:
-- 创建示范存储过程
create procedure mypro1(@strSql nvarchar(4000))
as
execute sp_executesql @strsql
go
-- 创建示范表并插入数据
create table test1 (id int primary key,name nvarchar(50));
insert into test1 values(100,'Johnson');
-- 将SQL语句作为参数在存储过程里执行
execute mypro1 'select * from test1;'
-- 删除示范对象
drop table test1;
drop procedure mypro1
你这个情况, 需要使用 Oracle 的 动态 SQL 的处理机制来处理的。可以看看 参考资料 中的例子。