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: Q: Newbie PL/SQL inquiry regarding existence check.

Re: Q: Newbie PL/SQL inquiry regarding existence check.

From: <nwhitehead_at_rocketmail.com>
Date: 1997/10/07
Message-ID: <343ab21c.3436771@news.cybernex.net>#1/1

What if you stated the following:

select foo into bar from my_table where foo like '%bar' and rownum=1;

Then, if you do not get an exception, then set the local to 1.

However, if you get a NO_DATA_FOUND exception, set the local to 0.

nick
nwhitehead_at_rocketmail.com

>Respects to all Oracle experts.
>I would like to find the most processing efficient solution to the
>following:
>
>Assume a table of records.
>I would like to query this table for the existence of one or more records
>meeting a WHERE clause criterion, and set a local PL/SQL variable
>to 1 if ANY records exist, and 0 if NO records exist.
>
>For instance, I could use:
>
>Select count(*) into <local_var> From <Table> Where <criteria>;
>
>However, could this be a very costly query for a very large table?
>
>Is there a better way....anyone?
>
>Thanks in advance.
>Posting and e-mail reply would be nice.
>
>Mick Davies, mdavies_at_elekom.com
Received on Tue Oct 07 1997 - 00:00:00 CDT

Original text of this message

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