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: 'IF EXISTS' functionality in Oracle SQL

Re: 'IF EXISTS' functionality in Oracle SQL

From: Niall Litchfield <n-litchfield_at_audit-commission.gov.uk>
Date: Thu, 16 Mar 2000 15:10:17 -0000
Message-ID: <8aqth1$hmg$1@soap.pipex.net>


"Steve Ball" <steve_at_REMOVEMEsdball.com> wrote in message news:38cce005$0$25792_at_lithium.news.uk.uu.net...
> All,
>
> I have some SQL written that worked on a Sybase or MS SQL Server db, but
not
> Oracle:
>
> if exists (select ...)
> update my_table
> set my_table.status = "65"
> where
> my_table.id = ...
>
> Basically, I'd like to find out if something exists, and if it does (or
> doesn't!) contain the data, I'd like to update the table.
>
> I don't think (I've looked) that there is the equivalent 'if exists' in
> Oracle, and I've looked at the decode statement, but I could not see that
it
> would work for what I wanted.

Hi

I've seen the replies that give you PL/SQl answers to this but suspect that you might just be after

update my_table
set my_table.status = "65"
where
my_table.id = ...
and not exists (select ....)

ytou can also use where exists for the opposite logic. Received on Thu Mar 16 2000 - 09:10:17 CST

Original text of this message

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