Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: If EXISTS before insert clause
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