mercredi 22 juillet 2020

Update columns based on condition PL/SQL setting them as NULL

I wanted to update columns based on condition: There is this table with columns A, B, C, D, E.

Table

These columns with values are to be updated with null. I do not want to touch the columns without any values.

...

UPDATE
    Table
SET 
  A = CASE WHEN A!=NULL THEN A=NULL
  B= CASE WHEN B!=NULL THEN B=NULL 
  C= CASE WHEN C!=NULL THEN C='U'
  D= CASE WHEN D!=NULL THEN D=NULL ELSE END,
WHERE
    where condition;

...

PS:: The column values are not same.

Aucun commentaire:

Enregistrer un commentaire