How do I compare a VARCHAR2
variable, which is an empty value?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Oracle doesn't differentiate between empty strings and NULL. To check if a variable is an empty string, use the IS NULL
syntax.
回答2:
You could use either of these:
IF v_test IS NULL
THEN
-- Business Logic
or
IF NVL(v_test, 'NULL') = 'NULL'
THEN
-- Business Logic
Your question does say "compare" a VARCHAR variable which is null so if you are comparing it to another variable then:
IF (v_test1 IS NULL and v_test2 IS NULL)
THEN
-- Business Logic
That would check if they are both null.
Hope it helps...