I am creating a fairly simple update statement that includes a nested case statement to determine the update value. The column description is the same nvarchar (32) for both fields.
code below
UPDATE TableA t SET t.Last_Col = ( CASE WHEN t.First_Col = 'ItemOne' THEN 'anItemOne' WHEN t.First_Col = 'ItemTwo' THEN CASE WHEN t.Second_Col = 'ItemTwo_A' THEN 'aSecondItem_A' ELSE 'aSecondItem' END ELSE 'NoItem' END );
This code works, but when I try to use t.First_Col instead of the string "NoItem", I get a character set mismatch.
ELSE t.First_Col END );
does not work. t.First_Col and t.Last_Col are both nvarchar2 (32), and I am trying to work with an application which, it seems to me, is not needed anyway.
ELSE CAST(t.First_Col AS NVARCHAR2(32)) END );
Any tips and tricks are welcome. As always, thanks in advance.
source share