SQL Default Question (Resent)

From: abc <abc_at_abc.com.au>
Date: Wed, 26 Feb 2003 14:40:37 +1100
Message-ID: <b3hcvh$rrm$1_at_mws-stat-syd.cdn.telstra.com.au>



[Quoted] Hi All,

[Quoted] [Quoted] I have a PL/SQL to do following calculation:

Total = NUM1 + NUM2;

SELECT a INTO NUM1 FROM T1;
SELECT b INTO NUM2 FROM T2;

As b has no return row therefore NUM2 is undefined. Total as a result is [Quoted] [Quoted] [Quoted] also undefined (PL/SQL crashed with "No defined value ...")

Is there any way to return b as ZERO if no row returned ???

I have tried

SELECT NVL(
    (SELECT b INTO NUM2 FROM T2), 0) FROM DUAL;

But PL/SQL did not allow me to use SELECT ...(SELECT !

SELECT NVL(NUM2,0) FROM DUAL doesn't work. Received on Wed Feb 26 2003 - 04:40:37 CET

Original text of this message