今天在Oracle 9i 的SQLPlusWorksheet中发现一个非凡怪奇的问题,看如下语句,是先清除sys_object表,然后在该表中insert3条数据,在Golden32的5.7版本中执行完全正常:
/*====================*/
/*Object Data */
/*====================*/
delete from sys_object;
/*Merchant*/
--Merchant Group
insert into sys_object("OBJECT_ID","OBJECT_NAME","MENU_ID","OBJECT_TYPE","OBJECT_USER","PROCESS","CREATE_USER","CREATE_TS","ITEM_SEQ","OBJECT_SEQ")VALUES('M_MERCGR','Merchant Group','M_MERC','W','A','merchant/mercgr_browse.ASP','SYSTEM',SYSDATE,3,4);
/*MPS Operation*/
insert into sys_object("OBJECT_ID","OBJECT_NAME","MENU_ID","OBJECT_TYPE","OBJECT_USER","PROCESS","CREATE_USER","CREATE_TS","ITEM_SEQ","OBJECT_SEQ")VALUES('M_OPER','MPS Operation',NULL,'M','A','','SYSTEM',SYSDATE,2,5);
--Payment Adjustment
insert into sys_object("OBJECT_ID","OBJECT_NAME","MENU_ID","OBJECT_TYPE","OBJECT_USER","PROCESS","CREATE_USER","CREATE_TS","ITEM_SEQ","OBJECT_SEQ")VALUES('M_PAYADJ','Payment Adjustment','M_OPER','W','A','operation/payadj_browse.asp','SYSTEM',SYSDATE,1,6);
commit;
但在Oracle 9i 的SQLPlusWorksheet中执行时,出现的提示却是这样的:
已删除3行。
已删除0行。
已创建 1 行。
insert into sys_object("OBJECT_ID","OBJECT_NAME","MENU_ID","OBJECT_TYPE","OBJECT_USER","PROCESS","CREATE_USER","CREATE_TS","ITEM_SEQ","OBJECT_SEQ")VALUES('M_MERCGR','Merchant Group','M_MERC','W','A','merchant/mercgr_browse.asp','SYSTEM',SYSDATE,3,4)
*
ERROR 位于第 1 行:
ORA-00001: 违反唯一约束条件 (HYH.PK_SYS_OBJECT)
已创建 1 行。
已创建 1 行。
提交完成。
我郁闷,语句好好的为什么会出错,看出错信息是表示在PK字段insert了重复的值,想了半天,顿悟!WorkSheet分明是在蒙我,数据我都delete了,而且俺的PK字段是OBJECT_ID字段,不可能有重复的,再仔细看一下返回信息,发现问题了,我明明只写了一条delete语句,却返回的两条delete信息,难道是delete执行了两次?假如是执行了两次,那么第二次执行的时候已经没数据了,所以delete了0,为什么执行了两次呢?
再看代码发现一个问题:
delete之后是注释块:/*Merchant*/
再看报PK错误的那一行:
之后也是注释块:/*MPS Operation*/
难道是/**/搞的鬼?
好,试一下,把两个注释块都改为--开头,再Run……
,正常了……,真是气死我了,果真是/**/的问题,那为什么为这个注释块没问题:
/*====================*/
/*Object Data */
/*====================*/
注:该块之前还是有其它语句的。
多次测试发现,/*后面直接跟26个英文字母的注释块会导致WorkSheet把该注释块前的语句重新执行一次!
/*大小写字母*/
其实似乎是:这样的注释/*大小写字母*/使SQLPlus Worksheet重新执行了缓冲区中的命令行!
不知我写的或我理解的对不对,
反正我的问题解决了,有疑问的话就自己试试吧