在proc中能编写支持自制事物的。

解决方案 »

  1.   

    create table t_test_autono
    (id number);CREATE OR REPLACE PROCEDURE proc_test_autono AS
      PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
      INSERT INTO t_test_autono VALUES (2);--自治事物插入数据
      COMMIT;
      INSERT INTO t_test_autono VALUES (1);--主事物插入数据
      ROLLBACK;--回滚主事物
    END;
    SQL> exec proc_test_autono;
     
    PL/SQL procedure successfully completed
     
    SQL> select * from t_test_autono;
     
            ID
    ----------
             2
     
    SQL>
      

  2.   

    但是存储过程中不能传超过4000字节的字符串了。varchar2类型有限制。我现在有需求需要传入clob类型的字段。存储过程能支持传clob类型字段吗?
      

  3.   

    可以 的 在声明的时候
    pragma autonomous_transaction;
      

  4.   

    EXEC SQL EXECUTE
            DECLARE
            PRAGMA  AUTONOMOUS_TRANSACTION;
    END-EXEC;
    这样声明 根本就编译不过。
    出现这样错误提示:
                PRAGMA  AUTONOMOUS_TRANSACTION;
    ................................1
    PLS-S-00103, Encountered the symbol "end-of-file" when expecting one of the foll
    owing:   begin function package pragma procedure subtype type use
       <an identifier> <a double-quoted delimited-identifier> form
       current cursorSemantic error at line 36, column 3, file mytest.pc:
                    DECLARE
    ..1
    PCC-S-02347, PL/SQL found syntax errors请问是怎么回事了。