Oracle Database: the DECODE function compares the value with a series of sequence dolls to determine the final returned results. The ordinal even is in pairs.
Oracle Database: the DECODE function compares the value with a series of sequence dolls to determine the final returned results. The ordinal even is in pairs.
Oracle Database:
The DECODE function compares the value with a series of sequence dolls to determine the final return result. We compare this function with the switch, and we find that they are basically similar. The only difference is that the values to be compared by the switch are added with break after the case.
Take the following example: (I found it online)
SELECT id,
DECODE (flag, 'y', 'yes', 'n', 'No', NULL, 'none', 'yes ')
FROM t_test;
If the flag field of t_test is Y, Yes is returned. If it is N, No is returned. If it is NULL, None is returned. Yes is returned by default.
Let's take a look at my problems:
SELECT a. id,
A. user_name,
A. oper_time time2,
A. oper_type,
A. description,
A. oper_flag,
Decode (a. oper_flag, '1', 'successfully', 'failed') oper_flag,
A. ip,
B. true_name
FROM SEC_LOG_OPERATION
Left join sec_user B on a. user_name = B. user_name
Where 1 = 1
Order by oper_time desc
The original red lines are: decode (a. oper_flag, 1, 'success', 'failed ')
I will report an error during the query, because the oper_flag field contains non-numeric data, that is, this field not only has 1, 0, but also "failed". This data! = Character. So we can process 1 as a character.