Problem while inserting a record into a table

From: Sandy80 <svarshneymail_at_gmail.com>
Date: Tue, 7 Sep 2010 04:44:59 -0700 (PDT)
Message-ID: <9fedb15e-becb-4e2c-8717-5d537d5a3670_at_d8g2000yqf.googlegroups.com>



hi,

I am trying to insert a record in a employee table 1 based on whether a record already exists in table 1. If a record for that employee already exists in table 1, I need to insert the record into table 2 else into table 1 itself. I am trying to do it through a pl/sql db procedure.
So the code I have for insert statement is as follows:

insert when (empno = 1234)

	then into table 2 (empname,empno)
        values (
	AAAA,
	1234

)
else into table 1(empname,empno) values ( AAAA, 1234
)
select * from table 1 where empno = 1234;

The insert statement works when there are no records in table 1 for that employee but fails when there are no records. Can anyone help me as what do I need to add/change in this query for it to work in both the conditions. Any help would be appreciated! Received on Tue Sep 07 2010 - 06:44:59 CDT

Original text of this message