今天在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重新执行了缓冲区中的命令行!
不知我写的或我理解的对不对,反正我的问题解决了,有疑问的话就自己试试吧