具体的意思是这样的:
CREATE OR REPLACE FUNCTION testExecute RETURN NUMBER IS
tmpVar NUMBER;
sqltemp varchar2(200);
 
BEGIN
   tmpVar := 0;
   
   sqltemp := 'select count(*) into tmpVar from gg_book ';
   
   --execute immediate sqltemp;
   
   select count(*) into tmpVar from gg_book;
   
   
   RETURN tmpVar;
   
END testExecute;我使用--execute immediate sqltemp;就提示错误,请那位大哥给点提示,谢谢了!

解决方案 »

  1.   

    execute immediate 主要用来执行DDL,函数中不能使用DDL。
    查询时直接执行select into即可,不要用execute immediate。
      

  2.   

    execute immediate
    用来执行单行操作。select into属于当行操作时可行的!
      

  3.   

    skystar99047(天星) 我需要拼出 select count(*) into tmpVar from gg_book  这句话,然后可以执行,请问这该怎么写?
      

  4.   

    sqltemp := 'select count(*)  from gg_book ';execute immediate sqltemp into tmpVar; --应该这样使用
      

  5.   

    to hongqi162(失踪的月亮) think you!i will have a try!