我在一个包中定义了个pipe funciton,在一个存储过程里面调用。今天报出异常
在存储过程里面编译时出现:
错误:PLS-00642: 在 SQL 语句中不允许使用本地收集类型
在sql窗口使用下面语句查看时select * from table(pkg_1.fun_1());
报出表函数fun_1处于不一致状态,这是什么原因。
我前几天运行好好的啊,今天也没动过。并且我查看了另一台机器上的完全相同的数据库,语法也是一摸一样。但那个问题

解决方案 »

  1.   


    把你的packagebody贴出来看看
      

  2.   

    包中定义大概是这样
    create record rec_1 is record
    (
       id number,
       name varchar2(10)
    )
    type tab_1 is table of rec_1
    type cur_1 is ref cursor return tab_1
    funciton pkg_1.fun_1() return tab_1 pipelined包体中的函数是这样的
    v_rec rec_1
    v_cur cur_1
    open cur_1 for select id,name from table_1
    loop
       fetch v_cur into v_rec
       exit when ....
       pipw row(v_rec)
    end loop这种错误是在什么情况下产生的呢??
      

  3.   

    PLS-00642 local collection types not allowed in SQL statements    Cause: A locally-defined (that is not schema level) collection type was used in a SQL statement. The type must be defined in a schema to be accepted in a SQL statement.    Action: Define the collection type in your schema, not inside a PL/SQL subprogram.
    你的type是定义在packagebody里的是是local definied,所以有错,你可以把type定义到scheam里。==================================================================
    Inthirties关注Oracle数据库 维护 优化,安全,备份,恢复,迁移,故障处理如果你需要帮助或想和我一起学习的请联系
    联系方式QQ:370140387
    QQ群:  85837884(注明:数据库)
    电子邮件:[email protected]
    网站: http://www.inthirties.com
      

  4.   

    包中定义的record和type只能在此包中使用。此时的type就像是类中的私有或者受保护成员变量,其他对象无法调用。