比较字符总是返回false

ala*_*bda 0 sql oracle plsql

我是PL/SQL的新手,我的存储过程已经存在问题.它编译,但一个IF语句永远不会按需运行.

IF SUBSTR(p_phone_number, 5, 1) <> '2' OR SUBSTR(p_phone_number, 5, 1) <> '6' THEN
    RAISE ex_phone_number_non_lv_custom2;
END IF;
Run Code Online (Sandbox Code Playgroud)

调用程序时,p_phone_number'+37122222222'类型的VARCHAR2(12).我使用了服务器输出,SUBSTR(p_phone_number, 5, 1)并且它是预期的2,但是这个IF语句仍然引发了我的异常.为什么会这样?

Gor*_*off 5

你想要的and...但更好的是,使用not in:

IF SUBSTR(p_phone_number, 5, 1) NOT IN ('2', '6') THEN
    RAISE ex_phone_number_non_lv_custom2;
END IF;
Run Code Online (Sandbox Code Playgroud)