Avatar of sam2929
sam2929
 asked on

update issue

Select works but when I do update I get error

UPDATE DIM t1
SET CURR_FLG=
SELECT
CASE WHEN A.RN=1 THEN 'Y' ELSE 'N' END as CURR_FLG
FROM
(
SELECT  
EMPLID,
EMPL_RCD,
EFFDT,
LST_ASGN_START_DT,
EMPL_STATUS,
ROW_NUMBER() OVER (PARTITION BY EMPLID,EMPL_RCD ORDER BY EFFDT DESC) AS RN
FROM DIM
WHERE EFFDT<=SYSDATE)A
WHERE t1.JOB_SID=A.JOB_SID
Oracle Database

Avatar of undefined
Last Comment
awking00

8/22/2022 - Mon
slightwv (䄆 Netminder)

What is the error?

When I see an update like this, I think of MERGE:
http://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_9016.htm#SQLRF01606

There are many examples out there.
slightwv (䄆 Netminder)

I just re-read the update statement.  Since you are updating the same table you are selecting from MERGE becomes more difficult.
sam2929

ASKER
Error at Command Line : 58 Column : 1
Error report -
SQL Error: ORA-00936: missing expression
00936. 00000 -  "missing expression"
*Cause:    
*Action:
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER CERTIFIED SOLUTION
slightwv (䄆 Netminder)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
awking00

Can you provide some sample data and the expected results from that data?