应该这样吧:
Select count(*) from A where field2='value'
假如count(*) >=1,就中不再执行插入任务,改为显示一条出错信息
你也可以看看我写的create or replace procedure P_Update(o_vc_message out varchar2)
is
type column1 is table of table1.column1%type index by binary_integer
col1s column1
type rid is table of rowid index by binary_integer
rids rid
temp table1.column1%type
begin
select column1,rowid bulk collect into col1s,rids from table1
if (column1.count != 0) then
for i in col1s.first..col1s.last loop
temp := col1s(i)--处理 col1s(i) 想干嘛干嘛
update table1 set column1 = temp where rowid = rids(i)
end loop
end if
o_vc_message := 'OK!'
exception
when others then
o_vc_message := 'exception happend.' || sqlcode || sqlerrm
rollback
return
end P_Update
如果仅仅是简单处理column1,比如加1什么的,就别搞那么复杂,一个sql就ok了。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)