user6260141 user6260141 - 3 months ago 10
SQL Question

oracle merge update not support set a constant?

MERGE INTO XXD_BORROW_REPAYMENT BR
USING XXD_BORROW B ON (B.BORROWID=BR.BORROWID AND B.type!=13)
WHEN MATCHED THEN
UPDATE SET BR.TOTALTERM=B.TIMELIMIT


MERGE INTO XXD_BORROW_REPAYMENT BR
USING XXD_BORROW B ON (B.BORROWID=BR.BORROWID AND B.type==13)
WHEN MATCHED THEN
UPDATE SET BR.TOTALTERM=1


why the first sql is right,the second sql is wrong, oracle merge not support set a constant?

Answer

From your statement "B.type==13" , it seems you wanted to implement a comparison of B.type with "13". Unfortunately oracle plsql doesnot support "==". You need to use a single "=" for any comparison. Look below the proof of concept for the same.

declare
var varchar(10):= '13';
begin

  if var == '13' then
   dbms_output.put_line('Hi');
 end if; 

end;

This simple block ends up thorwing an error: "Encountered the symbol "-" when expecting..."

Comments