Oracle empty conditions to check the ' ' c

2019-03-18 19:44发布

How do I compare a VARCHAR2 variable, which is an empty value?

标签: sql oracle null
2条回答
Juvenile、少年°
2楼-- · 2019-03-18 20:04

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...

查看更多
\"骚年 ilove
3楼-- · 2019-03-18 20:11

Oracle doesn't differentiate between empty strings and NULL. To check if a variable is an empty string, use the IS NULL syntax.

查看更多
登录 后发表回答