1753797 Members
8726 Online
108805 Solutions
New Discussion юеВ

Re: Update table

 
SOLVED
Go to solution
Avoiding the Red Zone
Occasional Contributor

Update table

Dear All,

I have a staging table called dept_management_stage which I have used SQL*LOADER to update the table this comprises of the following columns:

DEPT_ID
DEPT_NAME
START_DATE
END_DATE
COST_CENTER

What i want to do now is update dept_management from staging and seem to be not making progress. What I am trying to do is use 'update dept_management set dept_management = (select )' but can't seem to get the syntax to work could anyone help.

Thanks,
Angus
2 REPLIES 2
Sandman!
Honored Contributor
Solution

Re: Update table

Column name in UPDATE stmt. is same as table name. Change that to:

update dept_management
set DEPT_ID = (
select dept_id
from dept_management_stage)
/
spex
Honored Contributor

Re: Update table

Hi Angus,

Something like...

UPDATE dept_management dm
SET (dept_id, dept_name, start_date, end_date, cost_center) =
(
SELECT dept_id, dept_name, start_date, end_date, cost_center
FROM dept_management_stage dms
WHERE dms.dept_id = dm.dept_id
);

?

PCS