I think I am going wrong with Oracle SQL syntax. This is the syntax I use in Transact-SQL.
UPDATE "DE_OPS"
SET IMPORT_DATE = GETDATE()
WHERE PROCEDURE_CODE NOT IN ( SELECT DISTINCT PROCEDURE_CODE FROM DE_OPS_20140730 );
I reframed this for Oracle SQL as
UPDATE "DE_OPS"
SET IMPORT_DATE = SYSDATE()
WHERE PROCEDURE_CODE NOT EXISTS ( SELECT DISTINCT PROCEDURE_CODE FROM DE_OPS_20140730);
But this gives the error
Error at Command Line : 3 Column : 26
Error report -
SQL Error: ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:
Not sure where I am going wrong. Does "not exists" allow subqueries?
NOT EXISTSchanges what the statement does. The first one updates all rows with a matchingprocedure_code. The second one updates all rows if there is at no rowDE_OPS_20140730at all. Why did you change theNOT INtoNOT EXISTSin the first place? The syntax error however is unrelated to that: it'sSYSDATEnotsysdate().NOT INis fine with Oracle, just use SYSDATE instead of GETDATE()DISTINCTkeyword in your subquery. The outer query will only return one row per value in theNOT INandNOT EXISTSsubqueries, and includingDISTINCTonly adds overhead.