- 浏览: 647925 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (608)
- Java (125)
- Struts (16)
- Spring (19)
- iBatis (11)
- Hibernate (14)
- Oracle (33)
- Mysql (22)
- JBoss (4)
- JavaScript (46)
- Ajax (9)
- jQuery (5)
- web (25)
- Html (14)
- Exception (26)
- Linux (106)
- Vim (11)
- Python (12)
- ComputerTech (25)
- 文章 (50)
- Maven (20)
- FreeMarker (5)
- Json (0)
- Tomcat (6)
- ActiveMQ (2)
- Test (1)
- Git (5)
- Shell (1)
- 《Java并发编程实践》 (2)
- 产品设计 (1)
- xxx (0)
- diamond (1)
- dubbo (1)
- Raspbian (1)
- IDE (3)
- 并发编程 (1)
最新评论
-
mikzhang:
抱歉,写这篇文章时,博主开发的程序只面对IE浏览器,故没考虑其 ...
JS 中改变confirm默认按钮提示“确定""取消" -
poterliu:
测试过了,发现execScript方法只支持IE浏览器。目前已 ...
JS 中改变confirm默认按钮提示“确定""取消"
ORA-14551: cannot perform a DML operation inside a query
〖环境(Environment)〗
OS:SOLARIS 9
DB:ORACLE10G
〖现象(Symptom) 〗
Step01:创建函数f_stu。
SQL> create or replace function f_stu
2 return varchar2
3 is
4 username varchar2(20);
5 predicate varchar2(100);
6 begin
7 INSERT INTO student2 (ID,FIRST_NAME,LAST_NAME,MAJOR,CURRENT_CREDITS)
8 VALUES(001,'MARY','KING','history',0);
9 commit;
10 return 'ok';
11 end;
12 /
Function created
这个函数往表student2种插入数据。
Step02:在SELECT语句中调用函数f_stu。
SQL> select f_stu()from dual;
select f_stu()from dual
ORA-14551: cannot perform. a DML operation inside a query
ORA-06512: at "F_STU",line 7
〖原理(Cause) 〗
在SELECT语句中不能对表进行修改(insert,update,delete)。本例中,SELECT语句中的函数试图往表student2中插入数据。
〖方法(Action) 〗
要想在SELECT语句中对表进行修改,可以使用自治事务(Autonomous Transactions,AT)。自治事务(Autonomous Transactions)是由另外一个事务调用的,这个叫事务做主事务(Main Transaction,MT)。自治事务(Autonomous Transactions)的提交(commit)和回滚(rollback)并不影响主事务(MT)。
Step01:将创建函数f_stu()的SQL语句
由:
create or replace function f_stu
return varchar2
is
username varchar2(20);
predicate varchar2(100);
begin
INSERT INTO student2(ID,FIRST_NAME,LAST_NAME,MAJOR,CURRENT_CREDITS)
VALUES(001,'MARY','KING','history',0);
commit;
return 'ok';
end;
改成:
create or replace function f_stu
return varchar2
is
PRAGMA AUTONOMOUS_TRANSACTION;
username varchar2(20);
predicate varchar2(100);
begin
INSERT INTO student2(ID,FIRST_NAME,LAST_NAME,MAJOR,CURRENT_CREDITS)
VALUES(001,'MARY','KING','history',0);
commit;
return 'ok';
end;
加入了PRAGMA AUTONOMOUS_TRANSACTION,表示使用自治事务(Autonomous Transactions)。
Step02:再次在SELECT语句中使用函数。
SQL> select f_stu() from dual;
F_STU()
--------------------------------------------------------------------------------
ok
SELECT语句执行成功,同时也往表student2中插入了数据。
发表评论
-
Oracle_ojdbc6 使用 报错
2015-06-10 14:29 954via: http://sd8089730.iteye.c ... -
It is indirectly referenced from required .class file
2014-08-19 15:30 408via: http://www.blogjava.net/z ... -
Hibernate_a different object with the same identifier value was already associat
2014-07-05 17:03 484via: http://www.blogjava.net/h ... -
Connection reset by peer: socket write error
2013-03-14 10:24 825Connection reset by peer: soc ... -
java.sql.SQLException: 索引中丢失 IN 或 OUT 参数
2012-05-07 17:00 2532java.sql.SQLException: 索引中丢失 ... -
org.apache.coyote.tomcat5.CoyoteResponseFacade.sendRedirec
2012-03-19 15:25 1595【from http://www.cxy.me/bbs/vie ... -
request.getHeader("referer") is null
2012-03-19 15:23 927referer 用来判断上一页是不是自己的网站 如果我 ... -
Struts FileUpload - Processing of multipart/form-data request failed
2011-09-16 15:52 7266Struts FileUpload 异常处 ... -
HTTP Status 500 - No action instance for path could be created
2011-09-16 15:03 1680HTTP Status 500 - No action ... -
java.sql.SQLException: ORA-01830: date format picture ends before converting ent
2011-08-17 17:48 3370java.sql.SQLException: ORA-0 ... -
Bean property 'xxDao' is not writable or has an invalid setter method
2011-08-08 16:25 8700Bean property 'xxDao' is not ... -
SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null];
2011-08-04 15:38 2196网上解决方案 1.起初没有创建序列s_log,因此需要在Or ... -
org.xml.sax.SAXParseException: Document root element "struts-config", must match
2011-08-01 22:19 1648org.xml.sax.SAXParseException: ... -
Error creating form bean of class...
2011-08-01 10:44 985Error creating form bean of cla ... -
java.text.ParseException: Unparseable date: "11/10/10" at java.text.DateFormat.
2011-08-01 10:39 5570使用DateFormat的使用,然后自己试了下,结果出来个错误 ... -
[interceptor.FileUploadInterceptor:intercept] [Removing file filesXXX .tmp]
2011-07-25 11:18 4469上传完文件时控制台显示[interceptor.FileUpl ... -
The Network Adapter could not establish the connection
2011-07-15 17:05 12311、oracle配置 oracle9i2中把C:\ora ... -
java.sql.SQLException: ORA-00933: SQL 命令未正确结束
2011-06-30 12:16 2094java.sql.SQLException: ORA-0093 ... -
ORA-00942 Table or View Does Not Exist Oracle Error
2011-06-22 23:55 4414Cause: java.sql.SQLException: ... -
getOutputStream() has already been called for this response
2011-06-22 23:48 1595java.lang.IllegalStateExceptio ...
相关推荐
ora-01033:oracle initialization or shutdown in progress 解决方法 ora-01033:oracle initialization or shutdown in progress 解决方法 ora-01033:oracle initialization or shutdown in progress 解决方法 ora-...
在运行查询SELECT * FROM V$SESSION 会出现ORA-29275:部分多字节字符的错误,这是什么原因开始我不得其解,网上也没有介绍什么好办法。本文给出答案。
ORA-12154: TNS: 无法解析指定的连接标识符的解决方法
ORA-32001:write to spfile requested but no spfile is in use请求写入spfile,但没有使用spfile的解决方法 在输入以下语句中报了这样的错误: SQL>alter system set control_files=’/u01/app/oracle/oradata/prod/...
ORA-00031:标记要终止的会话解决方案; ORA-00031:标记要终止的会话解决方案;
ORA-01036:非法的变量名/编号 oracle特有的错误
调整参数后引起,ORA-00838: Specified value of MEMORY_TARGET is too small, needs to be at least 3 2768M 的解决方案
Oracle 回收站功能,彻底删除表ORA-00933:SQL command not properly ended,由于删除触发器引起的。数据交换不能再建触发器。
oracle 12 c ORA-01017: 用户名/口令无效; 登录被拒绝
NULL 博文链接:https://3w1h.iteye.com/blog/1211779
-- 解决ORA-00904: "WMSYS"."WM_CONCAT": 标识符无效 的文件包....... -- 解决ORA-00904: "WMSYS"."WM_CONCAT": 标识符无效 的文件包....... -- 解决ORA-00904: "WMSYS"."WM_CONCAT": 标识符无效 的文件包....... ...
oracle报错ora-12541:TNS无监听程序
解决ORACLE TNS: 无法解析指定的连接标识符; 里面有步骤
ORA-27300: OS system dependent operation:sskgxp_select failed with status: 3 ORA-27301: OS failure message: No such process ORA-27302: failure occurred at: skgxpvfymmtu ORA-27303: additional ...
最近在工作中遇到了一个问题,错误是Oracle dbca时报错:ORA-12547: TNS:lost contact,通过查找相关的资料终于找到了解决的方法,下面分享给大家,话不多说了,来一起看看详细的介绍吧。 环境: OS:RHEL6.5 x86-...
ORA-12518 TNS:监听程序无法分发客户机连接,在您安装好数据库后配置连接数据库的过程中遇到这类问题应该很头疼吧,不过,当您还是四处查资料来解决您遇到的另你头疼的问题时,如果不经意间看到了这则贴子,那请您升...
错误描述:oracle远程连接服务器出现 ORA-12170 TNS:连接超时 错误检查:有很多是oracle自身安装的问题,但是我这里服务器配置正常,监听正常,服务正常,远程可以ping通服务器。 这里主要是防火墙问题,解决办法: ...
ora-12514:TNS:监听程序当前无法识别连接描述符中请求的服务bug,解决文档.
CLOB字段类型报错 ORA-01704:文字字符串过长的解决