刚开始写存储过程,遇到一个比较大的问题。  
如下:  
test(strWhere  varchar2)  is  
begin  
   insert  into  table1  select  id  from  table2  where  strWhere;  
   commit;  
end;  
不可用,说是sql语句出现错误。  
我使用这个存储过程的原因是可以根据自己拼where条件,把符合条件的记录放到另外一张表中。请大侠们帮忙。谢谢!

解决方案 »

  1.   

    呵呵,用动态SQL,先预定义一个变量,就是你的strWhere。
    可参阅一下这方面的例子,或在本论坛中查找动态SQL就OK了。
      

  2.   

    str:='insert  into  table1  select  id  from  table2  where  '||strWhere;
    execute immediate str;
      

  3.   

    create or replace procedure test(strWhere in varchar2)  is  
    begin  
       insert  into  table1  select  id  from  table2  where  id=strWhere;  
       commit;  
    end;
      

  4.   

    各位大侠知道存储过程存放在oracle的哪个表或者视图里啊???