Hello Roland,

Do you even need PL/SQL for what you want to do?

rsis> I want to check whether field1 in table1 exists in
rsis> table3. If so then I want an insert statement to be
rsis> run...insert into table3

If the field *is* in table 3, you want to insert it into
table 3 again? I find that an odd requirement. However, you
might try something like:

INSERT INTO table3
   SELECT field1
   FROM table1
   WHERE field1 IN (SELECT DISTINCT field1 FROM table3);

EXISTS might work better than IN. You might need to adjust
your SELECT column list to match your target table. I don't
know what other columns are in table3. If table3 is really
large, I'd consider using EXISTS and getting rid of
DISTINCT. Well, you might need to try a few variations to
figure out which performs the best.

Best regards,

Jonathan Gennick --- Brighten the corner where you are
http://Gennick.com * 906.387.1698 * mailto:[EMAIL PROTECTED]

Join the Oracle-article list and receive one
article on Oracle technologies per month by 
email. To join, visit http://four.pairlist.net/mailman/listinfo/oracle-article, 
or send email to [EMAIL PROTECTED] and 
include the word "subscribe" in either the subject or body.


Monday, November 10, 2003, 9:54:25 AM, [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote:
rsis> Hallo,

rsis> I would like to do the following with an sql( pl/sql) statement.

rsis> I have table1 and table2 andtable3.

rsis> I want to check whether field1 in table1 exists in table3. If so then I want an 
insert statement to be run...insert into table3.....
rsis>  If it doesnt find that value then th escript will go to table2 and check if the 
vaules exists in that table, if it finds it then I want another insert statement to be 
run.

rsis> Please help me with an easy example, i dont know if this is so simply but I 
cantget it right though.


rsis> Thanks


rsis> Roland








rsis> -- 
rsis> Please see the official ORACLE-L FAQ: http://www.orafaq.net

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Jonathan Gennick
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to