Solved

No rows returned in subquery

Posted on 2003-11-24
4
943 Views
Last Modified: 2010-05-18
I have the following query in a PL/SQL block:

select nvl(include_in_dif, 1)
   into m_include_in_dif
  from pcc
 where pcc in (select nvl(pcc, 'NONE')
                 from gdls_z_expanded_boms
                where bomtype = 'MRP'
                  and partnum = 'DIFREPORT-001');

The Sub query returns no rows so the whole query returns nothing. I would like m_include_in_dif to default to '1' if no rows are returned. The above query does not do this of course.

Can I do this in one query. Any ideas ... ?

Romans
0
Comment
Question by:Romans
  • 2
  • 2
4 Comments
 
LVL 5

Expert Comment

by:FBIAGENT
ID: 9813141
have you try this?

select nvl(include_in_dif, 1)
   into m_include_in_dif
  from pcc
 where pcc in (select max(nvl(pcc, 'NONE'))
                 from gdls_z_expanded_boms
                where bomtype = 'MRP'
                  and partnum = 'DIFREPORT-001')
;

0
 

Author Comment

by:Romans
ID: 9813646
This ones not work FBIAGENT .... thanks for the input

Romans
0
 
LVL 5

Accepted Solution

by:
FBIAGENT earned 50 total points
ID: 9813822
this should work

have you try this?

select nvl(max(include_in_dif), 1)
   into m_include_in_dif
  from pcc
 where pcc in (select nvl(max(pcc), 'NONE'))
                 from gdls_z_expanded_boms
                where bomtype = 'MRP'
                  and partnum = 'DIFREPORT-001')
;
0
 

Author Comment

by:Romans
ID: 9814685
This one works ....

Thanks FBIAGENT

Romans
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now