PDA

View Full Version : SQL*plus Inserting new row with values = to existing rows data


Still
12-05-2005, 09:04 PM
Hi all

I am trying to insert a new employee into an empolyee table and get some of the values (namely phone no.) to be the same as what another employee currently has. This new employee is replacing the old employee, but i have to keep the old employee alive in the db as other data is reliant on its existance.

I was wondering how do i insert the new employee asking the, VALUE ('etc', 'etc',) line, to assign a value to certain fields equal to the value contained in other employee rows.

Any help would be great.

Thanks

TheShaner
12-05-2005, 09:06 PM
I would run a query to return the results of the old employee, store which results you need to keep in variables, and then create an insert query using the variables for the fields that need to be the same.

You won't be able to do what you're asking in just one query (at least I've never seen a way to do this).

-Shane

Still
12-05-2005, 09:09 PM
Thanks Shane

I was hoping there was a way but if not ill go the long way around.

Thanks again.