updatesql="update DocClauses set CLAUSEORDER=CLAUSEORDER-1 where (CLAUSEID=?) or (ITEMID=? and CLAUSEORDER=?) ";
解决方案 »
- orcle数据库中如何查询最新插入的数据
- oracle9i导出的数据库文件怎么导入oracle10g中
- oracle是否能跨越网段建立视图?
- 为什么自动备份数据库不能执行呢?急~!!!!!!!!! 在线等,高手们帮帮我好马?
- UPDATE问题 请教了~~~~
- jdbc调用带游标返回的存储过程,返回为空怎么判断(SQL当中带sum())
- SELECT REMAINDER(10,4) FROM DUAL;在Oracle 9i中執行為什么會報錯?
- 在select中,如何将返回的某行(字符串)与一个字符串相加?
- 有关managerserver启动的问题!(50)
- Oracle:如何用SQL将截图结果呈现出来
- into 问题
- 在oracle里面能不能进行与或非的操作?用什么运算符?
update DocClauses set CLAUSEORDER=CLAUSEORDER-1 where CLAUSEID=?;
update DocClauses set CLAUSEORDER=CLAUSEORDER+1 where ITEMID=? and CLAUSEORDER=?;
"
语句后加上分号
procedure proc_test(iCLAUSEID number, iITEMID number, iCLAUSEORDER number);
end cw;
/CREATE or Replace package body pktest is
procedure proc_test((iCLAUSEID number, iITEMID number, iCLAUSEORDER number)
as
begin
update DocClauses set CLAUSEORDER=CLAUSEORDER-1 where CLAUSEID=iCLAUSEID;
update DocClauses set CLAUSEORDER=CLAUSEORDER+1 where ITEMID=iITEMID
and CLAUSEORDER = iCLAUSEORDER ;
end proc_test;
是為什麼呢?两句SQL语句分開執行或合在一起執行在同一個事務下是完全沒有區別的!update table b
set b.id=
(
select a.id
from (
select id,id-1 id_x from table
where id = 8
union
select id,id+1 id_x from table
where id = 7
) a
where b.id=a.id_x
)
where b.id in (7,8);
('A','A',
2 (CLAUSEID='487'),'B',(ITEMID='484' and CLAUSEORDER='3'));
(CLAUSEID='487'),'B',(ITEMID='484' and CLAUSEORDER='3'))
*
ERROR 位于第 2 行:
ORA-00907: 缺少右括号
CLAUSEID=? 和 ITEMID=? and CLAUSEORDER=? 都满足,执行什么?
update DocClauses set CLAUSEORDER = (
select CLAUSEORDER-1 where CLAUSEID=?
);
update DocClauses set CLAUSEORDER=CLAUSEORDER-1 where CLAUSEID=?";
tempsql="update DocClauses set CLAUSEORDER=CLAUSEORDER+1 where ITEMID=? and CLAUSEORDER=?";
如果没有同时满足CLAUSEID=? 和 ITEMID=? and CLAUSEORDER=? 这种情况则可以这样写:
update DocClauses a
set CLAUSEORDER = (
select CLAUSEORDER-1 from DocClauses b
where a.识别码= b.识别码 and CLAUSEID=?
union
select CLAUSEORDER-1 from DocClauses b
where a.识别码= b.识别码 and ITEMID=?
and CLAUSEORDER=?
)
where CLAUSEID=? or (ITEMID=? and CLAUSEORDER=?);
如果有那种情况则要再加个查询:
update DocClauses a
set CLAUSEORDER = (
select max(c.aa) --你要的函数
from
(select CLAUSEORDER-1 aa from DocClauses b
where a.识别码= b.识别码 and CLAUSEID=?
union
select CLAUSEORDER+1 aa from DocClauses b
where a.识别码= b.识别码 and ITEMID=?
and CLAUSEORDER=?
)c
)
where CLAUSEID=? or (ITEMID=? and CLAUSEORDER=?);