Posted by: rawbee June 12, 2008
ORACLE Constraints help
Login in to Rate this Post:     0       ?        

HELLO arnzombie Jee,

I dont have much idea about Oracle but i will give you idea in  SQL.

- first create temp table and insert value in temp table first.
- Insert into B if only exists in A from temp table
-Finnaly drop temp table

Here is in sql

DECLARE @TEMP TABLE
(ID INT,
NAME VARCHAR(50),
SHIP VARCHAR(50)
)

INSERT INTO @TEMP VALUES(5,'ZZZ','ZZZ')

INSERT B

SELECT * FROM @TEMP T WHERE EXISTS(SELECT A.ID FROM A WHERE A.ID = T.ID)

It wont do any thing if Id is not exists in Table A. if You need error message you can use raseerr functuon

All the best.

Read Full Discussion Thread for this article