问题1:表1 有  key,a,b,c,d,e,f,bz 几个字段存储过程中 能否判断  a b c d e f 任一个字段为空或<0  则bz 从 null 更新为 1
问题2:表2: 有 date 型字段  a ,b,key  key 与表1关联存储过程中能否做到  通过key的关联  在满足条件 a<b时 将表1中的bz更新为1
谢谢。 存储过程写的少 百度来的又不得其法顺祝各位国庆快乐

解决方案 »

  1.   

    if a is null or a<0 or b is null or b <0.... thenend if;根本就不用存储过程,一个update语句足够
      

  2.   


    --1、可以直接一个SQL解决..写过程的话..思路一样..根据下面的子查询 查询出匹配你条件的KEY 然后更新BZ字段
    update table set bz = '1' where key in
    (select key from table where  (a is null) or (b is null) or (c is null)....)
    --2、也可以直接用一个SQL解决,用过程的话也是一样..把下面的SQL分成两句,子查询建立个游标,遍历结果集,然后根据KEY更新表1
    update 表1 set bz = '1' where key in
    (select key from 表2 where to_char(a,'yyyymmdd') < to_char(b,'yyyymmdd'))