In Oracle, an empty string is treated as NULL, and any value with a null comparison result is null. As a result, an exception occurs when you compare two strings. Take a look at the following example:
declare I VARCHAR2: = null; v VARCHAR2 (Ten): = ' ABC '; begin IF (i = v) then Dbms_output. Put_Line (' equal '); else Dbms_output. Put_Line (' unequal '); END IF; End; Please judge with your clever mind, what should be the result? It's easy to get the result: ' Unequal '. Very well, you are right. The result of running on Sqlplus is the same as what you think. Then I change the program, you can judge:declare I VARCHAR2: = null; v VARCHAR2 (Ten): = ' ABC '; begin IF (i <> v) then Dbms_output. Put_Line (' unequal '); else Dbms_output. Put_Line (' equal '); END IF; END; It seems that there is not much difference between the first program, it is easy to get the result: ' Unequal '. Oh. Are you sure this is the result? Then please test it in sqlplus to verify that you are right. Unfortunately, the correct result should be: ' equal '. Are you surprised? As we said at the beginning: any value with a null comparison result is null. That is, the result of a i=v comparison in the first program should be null, and the result of the I<>v comparison in the second program is null. When the condition in the if structure is null, the current branch is skipped into the else or the end. Can't you? Then you run the following program will be able to wait until validation:begin IF (NULL) then Dbms_output. Put_Line (' not NULL '); else Dbms_output. Put_Line (' NULL '); END IF; end; The result is output: ' NULL '.
Comparison of NULL characters in Oracle