专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Oracle技术

Oracle update1条记录,该如何处理

发布时间:2010-05-20 14:01:29 文章来源:www.iduyao.cn 采编人员:星星草
Oracle update1条记录
从java程序中,循环生成了196个编码,需要分别更新到数据库中的196条记录中
每循环一次,需要执行一个update语句,将1个编码更新到数据库196条记录中任何一条
再次循环,再次更新
我的sql语句是这样写的:
create or replace procedure pro_ghxCode(p_ghxCode in varchar2)
is
begin
   
  update card_zonghe a set a.emscode = p_ghxCode
  where a.cardno in (select cardno from card_in_out_store 
  where riqi = to_char(sysdate,'yyyymmdd')) 
  and is_mailing = 'Y' 
  and yjflag = '1' 
  and store_state = 'ZKZX' 
  and card_state = 'PRE_STORE_OUT'
  and rownum = '1';

  
  commit;
end pro_ghxCode;
用rownum = '1'第一次可以保证1个编码更新到一条记录中
第二次就不可以了,总之rownum 是不可取的
各位高手,有没有好的解决办法啊?

------解决方案--------------------
更新前emscode字段有值吗,如果没有的话可以用这个字段判断.
SQL code
update card_zonghe a set a.emscode = p_ghxCode,a.标识字段名='Y'
  where a.cardno in (select cardno from card_in_out_store  
  where riqi = to_char(sysdate,'yyyymmdd'))  
  and is_mailing = 'Y'  
  and yjflag = '1'  
  and store_state = 'ZKZX'  
  and card_state = 'PRE_STORE_OUT'
  and emscode is null--这里改成 and 标识字段名='N'
  and rownum = 1;
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: