数据库

 首页 > 数据库 > Oracle > ORA-14551:无法在查询中执行DML操作的解决方法

ORA-14551:无法在查询中执行DML操作的解决方法

分享到:
【字体:
导读:
         摘要:--创建测试表createtablefn_dml_test(IDNUMBER(20),textVARCHAR2(200))--创建函数CREATEORREPLACEFUNCTIONfn_test(IDNUMBER)RETURNNUMBERIS/*14551,00000,"cannotperforma... ...

ORA-14551:无法在查询中执行DML操作的解决方法

--创建测试表
create table fn_dml_test
  ID    NUMBER(20),
  text  VARCHAR2(200)
)
 
--创建函数
CREATE OR REPLACE FUNCTION fn_test(ID NUMBER) RETURN NUMBER
IS
/*
14551, 00000, "cannot perform a DML operation inside a query "
// *Cause:  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.  www.2cto.com  
*/
pragma  AUTONOMOUS_TRANSACTION;
BEGIN
  INSERT INTO fn_dml_test(id,text) values(ID,'success');
  COMMIT;
  RETURN 1;
EXCEPTION
  WHEN OTHERS THEN
  INSERT INTO fn_dml_test(id,text) values(ID,'fail');
  COMMIT;
  RETURN 0;
END;
 
--查询验证
SELECT fn_test(1) from dual
 
 
 
摘自 gdolphinw的专栏
ORA-14551:无法在查询中执行DML操作的解决方法
分享到:
oracle中外关联的解惑
oracle中外关联的解惑 一、left join的on条件:   1、简单的left join(right join同理)。   01 SQL> select * from p1; 02  www.2cto.com     03 A                    B                    C 04 -------------------- -------------------- -------------------- 05 1              ...
oracle数据库分配表空间、创建用户、分配...
oracle数据库分配表空间、创建用户、分配用户权限操作 oracle数据库分配表空间、创建用户、分配用户权限操作   1、创建临时表空间   /* create temporary tablespace*/ create temporary tablespace student_temp   tempfile 'D:\oracle\product\10.2.0\oradata\Student\student_temp.dbf'  size 50m   au...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……