Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Q: Newbie PL/SQL inquiry regarding existence check.
If you're using PL/SQL, just use a cursor. Open it, and do only one fetch.
if cursor_name%FOUND, then that means at least one record exists for that
condition.
Don't forget to close the cursor.
Mick Davies wrote:
> 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 Wed Oct 08 1997 - 00:00:00 CDT
![]() |
![]() |