Using DECODE function in UPDATE statement [message #20813] |
Sun, 23 June 2002 03:15 |
Azzah Al-Sayegh
Messages: 3 Registered: June 2002
|
Junior Member |
|
|
Can I use the DECODE function to minimize the below coding?
IF condition = A THEN
UPDATE table_T
SET col_A = X;
ELSIF condition = B
UPDATE table_T
SET col_B = X;
ELSIF condition = C
UPDATE table_T
SET col_C = X;
ELSE
UPDATE table_T
SET col_D = X;
END IF;
Please note that I am updating different columns in the same table according to cetrain condition.
Thanks.
|
|
|
Re: Using DECODE function in UPDATE statement [message #20815 is a reply to message #20813] |
Sun, 23 June 2002 10:40 |
Pablo Martinez
Messages: 2 Registered: June 2002
|
Junior Member |
|
|
Hello.
Perhaps something like this could work:
UPDATE table_T
SET col_A = DECODE (condition,A,X,NULL),
col_B = DECODE (condition,B,X,NULL),
col_C = DECODE (condition,C,X,NULL),
col_D = DECODE (condition,D,X,NULL);
Hope this helps
Regards, Pablo
|
|
|
|