create table tmp_table
(
ID number(10),
PRODUCTNAME varchar2(100)
);
create or replace package my_query is 
                  type rec_xscx is record(ID number(10),
PRODUCTNAME varchar2(100));
                     type ref_cur1 is ref cursor return rec_xscx;
               procedure q_xscx(c1 in out ref_cur1);
end;
/
create or replace package body my_query is
 procedure q_xscx(c1 in out ref_cur1) is
 begin
                                insert into tmp_table 
select ID,PRODUCTNAME from pro_product where productname like '
%空调%';
 end;
 end;
 /
variable x refcursor
execute my_query.q_xscx(:X);
print x;
ERROR:
ORA-24338: 未执行语句句柄  输出时出现这个         
还有这样带游标的  在php代码里如何调用啊  

解决方案 »

  1.   


    ORA-24338: 未执行语句句柄
        这个问题主要出现在使用数据库游标的时候.当执行存储过程,返回的游标没有打开时,可能会报这个错。
        游标没有打开的情况一般是忘记了写打开游标的语句,
        也可能是存储过程中执行出错,导致最后游标未打开。
    --给你修改了一下,试试看:
    create or replace package body my_query is
     procedure q_xscx(c1 in out ref_cur1) is
     begin
          insert into tmp_table  
          select ID,PRODUCTNAME 
          from pro_product 
          where productname like '%空调%';
          commit;
          open cl for
          select id,productname
          from tmp_table;
          exception
                   when others then
                   rollback;
     end;
     end;
     /
      

  2.   

     PL/SQL: SQL Statement ignored
     PLS-00201: 必须声明标识符 'C            还是有错误   谢谢你的回帖 能在帮看看看吗 ?? 
      

  3.   


    /*
    PLS-00201: 必须声明标识符 PL/SQL: Statement ignored
    原因一:用户不对
    原因二:存储过程不存在或包名前辍没加
    */
    create table tmp_table(
           id number(10),
           productname varchar2(100)
    );
    /
    create or replace package my_query is  
    /*  type rec_xscx is record(ID number(10),不知道你定义这个记录类型有何用途
                              PRODUCTNAME varchar2(100));*/
      type ref_cur1 is ref cursor;
      procedure q_xscx(c1 in out ref_cur1);
    end;
    /
    create or replace package body my_query is
     procedure q_xscx(c1 in out ref_cur1) is
     begin
          insert into tmp_table  
          select id,productname 
          from pro_product 
          where productname like '%空调%';
          commit;      open cl for
          select id,productname
          from tmp_table;
          
          exception
                   when others then
                   rollback;
     end q_xscx;
    end my_query;
    /