【问题标题】:Oracle Apex get first part of PostcodeOracle Apex 获得邮政编码的第一部分
【发布时间】: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


    【解决方案1】:

    您可以使用正则表达式来获取第一个只有字符的子字符串,例如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() functionOracle's support regular expressions 的信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-11
      • 2020-04-21
      • 2020-01-22
      相关资源
      最近更新 更多