【发布时间】:2015-05-19 15:36:09
【问题描述】:
目前我的工作效率并不高。对于我遇到的问题,我几乎可以肯定有一种更智能、更好的方法来解决它。
我正在尝试做的事情: 我得到一个这样的字符串:
'NL 4633 4809 KTU'
NL 是现有表格中的国家/地区代码,KTU 是现有表格中的大学代码。我需要将此字符串放入我的函数中并检查该字符串是否经过验证。
在我的函数(验证字符串)中,这是我正在处理的。我已经设法用这个分割字符串:
countryCode := checkISIN; -- checkISIN is the full string ('NL 4633 4809 KTU') and I am giving the NL value to this variable. countryCode is the type varchar2(50)
countryCode := regexp_substr(countryCode, '[^ ]+', 1, 1);
现在我有了如下所示的国家代码:
NL
Has valid country code
我想从它自己的表中验证/检查国家代码是否存在。我试过这个:
if countryCode in ('NL', 'FR', 'DE', 'GB', 'BE', 'US', 'CA')
then dbms_output.put_line('Has valid country code');
else
dbms_output.put_line('Has invald country code. Change the country code to a valid one');
end if;
这可行,但不是动态的。如果有人添加了国家代码,那么我必须再次更改该功能。
那么有没有一种(智能/动态)方法来检查他们现有表格的国家代码?
希望我的问题不要太含糊
干杯
【问题讨论】:
-
[参考您的解决方案][1],我认为同样的问题您已经重复超过 2 次 [1]:stackoverflow.com/questions/30311746/…
标签: regex oracle if-statement oracle11g