当前位置: 代码迷 >> Oracle管理 >> oracle select语句怎么进行判断
  详细解决方案

oracle select语句怎么进行判断

热度:102   发布时间:2016-04-24 04:15:49.0
oracle select语句如何进行判断。
小弟遇到个开发问题:
两个select语句  A  B;
A:select  av.name from supliers av where av.seg = '1000'
B:select vl.description    from  FND_FLEX vl where  vl.SET_ID = '1013717' and vl.ENABLED = 'Y'and vl.MEANING ='10'

如何当A查询出来的值为   没记录(不是空值)  
然后进行B查询,

最后得出来的结果是给一个表的字段赋值。

原来语句是
create or replace view cux_shipment_delivery_list_v as
select  csdl.delivery_number, (select  av.name from supliers av where av.seg = '1000')destination   from cux_delivery_list  csdl 
------解决方案--------------------
select  csdl.delivery_number, nvl((select  av.name from supliers av where av.seg = '1000'),
  (select vl.description    from  FND_FLEX vl where  vl.SET_ID = '1013717' and vl.ENABLED = 'Y'and vl.MEANING ='10'))
destination   from cux_delivery_list  csdl 

是这个意思吧
------解决方案--------------------
select vl.description    from  FND_FLEX vl where  vl.SET_ID = '1013717' and vl.ENABLED = 'Y'and vl.MEANING ='10'
 and not exists(select  1  from supliers av where av.seg = '1000')
A中不存在记录的时候执行B
------解决方案--------------------
create or replace view cux_shipment_delivery_list_v as
select  csdl.delivery_number, (select  av.name from supliers av where av.seg = '1000')destination   from cux_delivery_list  csdl 
where exists (select  av.name from supliers av where av.seg = '1000')
union all
select  csdl.delivery_number, (select vl.description  from  FND_FLEX vl where  vl.SET_ID = '1013717' and vl.ENABLED = 'Y'and vl.MEANING ='10')destination   from cux_delivery_list  csdl 
where not exists (select  av.name from supliers av where av.seg = '1000')
  相关解决方案