永发信息网

我有一个存储过程,执行一次会将数据插入一张新表. 之后我又有一个存储过程,用来更新新表的字段数据,

答案:2  悬赏:70  手机版
解决时间 2021-02-07 16:25
  • 提问者网友:浩歌待明月
  • 2021-02-07 13:18
问题是:我更新新表的存储过程中 有些id是不存在的,那么我要将其插入,用sql exists 怎么用啊,
最佳答案
  • 五星知识达人网友:独行浪子会拥风
  • 2021-02-07 14:14
if exists(select id from B where ID not in (select id from A)) exec 存储过程1
全部回答
  • 1楼网友:你可爱的野爹
  • 2021-02-07 14:57
pc_id,screen_id哪个优先?以pc_id优先为例: oracle用decode函数,sqlserver可以用case...when,给你个oracle的例子 create procedure add_table is begin insert into wip_led_opration(operation_id,led_pc_id,led_screen_id) select operation_id,led_pc_id, decode(led_pc_id,null,led_screen_id,null) -- 逻辑:第三列led_screen_id,先判断led_pc_id是否为空,为空则用led_screen_id,非空即led_pc_id存在,则led_screen_id列位置留空 from fnd_led_pc ,fnd_led_screen ,fnd_operation where fnd_operation.status=1 and fnd_led_screen.status=1 and fnd_led_pc.status=1 -- and fnd_operation.status=fnd_led_screen.status --这个条件是多余的,两个值都=1了 and fnd_led_screen.status=fnd_led_pc.status ; end;
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯