Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL Default Question (Resent)

Re: SQL Default Question (Resent)

From: JustAnotherDBA <jadba_at_bellsouth.net>
Date: Tue, 25 Feb 2003 23:31:34 -0600
Message-ID: <3317a.43293$GA2.14744@fe09.atl2.webusenet.com>


I would declare the select cursor in the declare section (without the into parameter) and then you can have control by doing fetch into and then checking the cursor-name%notfound value and setting num2 accordingly.

I do not like to say read the manual, but there is probably an example for what I am saying to do. If you don't have an example by tomorrow, post a reply and I will post an example, but it will be most likely later in the day after 7:00PM Central Time Zone USA.

Oh yeah, I removed the other newsgroups because it seems to bother a lot of people. So, please do not add them back.

"abc" <abc_at_abc.com.au> wrote in message
news:b3hcvh$rrm$1_at_mws-stat-syd.cdn.telstra.com.au...
> Hi All,
>
> 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
> 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 Tue Feb 25 2003 - 23:31:34 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US