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: IF NOT EXISTS SELECT ...

Re: IF NOT EXISTS SELECT ...

From: Thomas J. Kyte <tkyte_at_us.oracle.com>
Date: 1996/10/15
Message-ID: <3262f788.1304145@dcsun4>#1/1

On 15 Oct 1996 11:32:11 GMT, eraarm_at_hfera.ericsson.se (Armin S. Seidel LK/NKG) wrote:

>I would like to test the existence of rows as condition
>in a PL/SQL if-clause:
> IF NOT (EXISTS SELECT * FROM table WHERE col = value) THEN
> ...
> END IF;
>

use:

  select count(*) into N from dual
  where exists ( select NULL from table where col = value );

  if ( n = 0 ) then
    ....
  end if;

>but Oracle complains about the syntax. I tried different variations
>with/without parentheses without success.
>Apparently, the EXISTS operator may only be used in subqueries.
>Can you help?
>
>-- Armin
>_______________________________________________________________________
>Armin.Seidel_at_hfera.ericsson.se KI/ERA/LK/NK +46(0)8-404 2456
> extr.qraarmi@memo.ericsson.se http://www.hfera.ericsson.se:/~eraarm/
> armin_at_independent.se www.independent.se +46(0)70-7277822
>

Thomas Kyte
Oracle Government
tkyte_at_us.oracle.com                          

http://govt.us.oracle.com


statements and opinions are mine and do not necessarily reflect the opinions of Oracle Corporation Received on Tue Oct 15 1996 - 00:00:00 CDT

Original text of this message

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