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 before insert clause

Re: If EXISTS before insert clause

From: Malcolm Dew-Jones <yf110_at_vtn1.victoria.tc.ca>
Date: 4 Feb 2005 13:16:48 -0800
Message-ID: <4203e640@news.victoria.tc.ca>


JPike (jpike_at_welcom.com) wrote:
: In my sql script file for SQL Server I have:

: IF EXISTS(SELECT PRD_UID FROM WST_PRD WHERE PRD_UID = 502)
: BEGIN
: INSERT INTO WST_PFD (PFG_UID, OBJ_UID) VALUES('14014', 'GRP_VIEW_RSK')
: .
: .
: .
: END

: Basically I want to see if an entry exists, reflecting that a product
: in installed, and if so run a group of inserts, etc.

: This works fine in SQL Server but Oracle is not liking it. I know IF
: EXISTS doesn't exist here so how should I best do this to run in a
: script file?

PL/SQL or (my syntax might not be quite right)

INSERT INTO WST_PFD (PFG_UID, OBJ_UID)
  select '14014', 'GRP_VIEW_RSK'
  from some_table_such_as_DUAL
  where exists
  (

     SELECT PRD_UID FROM WST_PRD WHERE PRD_UID = 502   )
;

--

This space not for rent.
Received on Fri Feb 04 2005 - 15:16:48 CST

Original text of this message

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