Home » SQL & PL/SQL » SQL & PL/SQL » IF..THEN statements
IF..THEN statements [message #293416] Sat, 12 January 2008 07:11 Go to next message
mandavanpraag
Messages: 1
Registered: January 2008
Junior Member
Hello,
I am trying to use an IF statement to insert data into another table where the ID numbers are the same as the data already present .
Here is the code I have so far:


INSERT INTO projs
SELECT project_name,
project_id
FROM
CLIENT_PROJECT;

IF CLIENT_PROJECT.project_id = projs.project_key
INSERT INTO tmp_load;


this code brings up errors when i try to run it. Any ideas would be greatly appreciated.

many thanks
Amanda.
Re: IF..THEN statements [message #293420 is a reply to message #293416] Sat, 12 January 2008 08:41 Go to previous messageGo to next message
BlackSwan
Messages: 25039
Registered: January 2009
Location: SoCal
Senior Member
http://www.orafaq.com/forum/t/88153/0/
Read & FOLLOW posting guidelines as stated in URL above

http://www.oracle.com/pls/db102/homepage?remark=tahiti
URL above has links to both the SQL Reference Guide & PL/SQL Reference Guide which show what is valid syntax.

[Updated on: Sat, 12 January 2008 08:42] by Moderator

Report message to a moderator

Re: IF..THEN statements [message #293422 is a reply to message #293416] Sat, 12 January 2008 09:14 Go to previous message
Michel Cadot
Messages: 64116
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
This is a simple join condition.
By the way, the name of the target table "tmp_load" smells the bad program design for Oracle.

Regards
Michel
Previous Topic: Complex Days Count In One SQL
Next Topic: Update using sequence
Goto Forum:
  


Current Time: Tue Dec 06 02:25:23 CST 2016

Total time taken to generate the page: 0.16221 seconds