【发布时间】:2015-03-15 06:18:16
【问题描述】:
甲骨文 11g
APEX 4.2.6.00.03
我在表单中有邮政编码字段。例如。 (L10 1TY 或 WF2 5TG 或 W7 5RR)
我还有一个区域查找表,从中可以找到一个区域
例如。
- L = 区域 1
- WF = 区域 2
- W = 区域 3
如何获取邮政编码的第一部分,以便根据区域表查找值。
【问题讨论】:
标签: oracle oracle11g oracle-apex
甲骨文 11g
APEX 4.2.6.00.03
我在表单中有邮政编码字段。例如。 (L10 1TY 或 WF2 5TG 或 W7 5RR)
我还有一个区域查找表,从中可以找到一个区域
例如。
如何获取邮政编码的第一部分,以便根据区域表查找值。
【问题讨论】:
标签: oracle oracle11g oracle-apex
您可以使用正则表达式来获取第一个只有字符的子字符串,例如regexp_substr(postcode, '^[[:alpha:]]+')
例如:
with t as (
select 'L10 1TY' as postcode from dual
union all select 'WF2 5TG' from dual
union all select 'W7 5RR' from dual
)
select postcode, regexp_substr(postcode, '^[[:alpha:]]+', 1, 1) as region
from t;
POSTCODE REGION
-------- -------
L10 1TY L
WF2 5TG WF
W7 5RR W
在手册中了解更多关于 the regexp_substr() function 和 Oracle's support regular expressions 的信息。
【讨论】: