select AAA.FAAA('100001', '20060828') from dual;
記錄集(VB): rs.open "select AAA.FAAA('100001', '20060828') from dual",connection..
kkk=rs.fields(0).value 

解决方案 »

  1.   

    可以是可以,但是如果在packege body里写insert或者delete等语句,就会报错。
    CREATE OR REPLACE PACKAGE BODY AAA
    AS
      FUNCTION FAAA (
    VAL1 IN CHAR,
    VAL2 IN CHAR
      ) return NUMBER
      IS    BEGIN  INSERT INTO CCC(ddd) VALUES(VAL1);
    commit;
            RETURN 0;
      END FAAA;
    END AAA;
    报的错误是:ORA-14551:connot perform a DML operation a query 
    以上有问题吗?
      

  2.   

    Oracle Pkg里能执行任何的DML语句,你的这个问题应该是事务控制的问题.ORA-14551 cannot perform a DML operation inside a queryCause: DML operation like insert, update, delete or select-for-update cannot be performed inside a query or under a PDML slave.Action: Ensure that the offending DML operation is not performed or use an autonomous transaction to perform the DML operation within the query or PDML slave.
      

  3.   

    函数中如果有insert/delete/update操作,那么这个函数不能用在select语句中,如果用了,就会报ORA-14551
      

  4.   

    最后自己终于发现,解决这个问题很简单,也不用dual了,直接这样写就可以调用了,晕阿。BEGIN
      :BND_RETURN := AAA.FAAA('100001', '20060828');
    END;谢谢大家的帮助,还是学到了很多知识。