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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Return value assigned to a number from an empty query.

Re: Return value assigned to a number from an empty query.

From: Steve M <steve.mcdaniels_at_vuinteractive.com>
Date: Mon, 4 Feb 2002 13:36:26 -0800
Message-ID: <a3muk8$474$1@spiney.sierra.com>


select COUNT(*) into my_number from my_table...

when there are no rows which match the criteria, the result will be 0 (zero).

For numbers this works fine:

SQL> select count(*) from dual where 1=2;

 COUNT(*)


        0

For non-numbers, consider this:

SQL> select * from dual where 1=2;

no rows selected

In this case, you would need an EXCEPTION hander:

select my_field into MY_VARIABLE from my_table where.... exception
  when no_data_found then

     MY_VARIABLE := some_default_value;

"Craig Lehn" <clehn_at_consystint.com> wrote in message news:3c5ee3ea$1_7_at_goliath.newsgroups.com...
> What is the return value assigned to say a number when I preform a query
> that returns nothing how do I use an equal if statemen?
> if number = then
> number := 0;
>
>
>
>
> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> Check out our new Unlimited Server. No Download or Time Limits!
> -----== Over 80,000 Newsgroups - 19 Different Servers! ==-----
Received on Mon Feb 04 2002 - 15:36:26 CST

Original text of this message

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