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; /* 另外提几点建议 1. 建议给三个表加上别名 2. 多余的连接条件我注释掉了,虽然对执行计划应该没有太大影响 3. SELECT后最好标识出源表,比如fnd_operation.operation_id,这样自己看着也清楚 */
{[MIMIcall]]不错的软件