select LPAD(a1,4,'0')||LPAD(a2,3,'0')||LPAD(a3,2,'0')||LPAD(a4,4,'0') from T

解决方案 »

  1.   

    select LPAD(a1,4,'0')||LPAD(a2,3,'0')||LPAD(a3,2,'0')||LPAD(a4,4,'0') from T
      

  2.   

    select LPAD(a1,4,'0')||LPAD(a2,3,'0')||LPAD(a3,2,'0')||LPAD(a4,4,'0') from T
    那将‘金海湾B区11-1702‘ ’金海湾B区11-1-1702‘进行字符串分割成’金海湾B区‘  ’11‘  ’0‘  ’1702‘和’金海湾B区‘  ’11‘  ’1‘  ’1702‘呢
      

  3.   

    这个只能使用正则表达式了,相对麻烦一点,手上有点事,一会再帮你写
    写个存储过程吧,将分割成的数据update到表中
      

  4.   

    REGEXP_COUNT(TEMP,'[0-9]+')
    如果是低版本可以用下面的语句替换
    length(temp)-length(replace(temp,'-',''))+1
      

  5.   

    想用ltrim去左端多余的0的话,那像’金海湾B区11-1702‘中间那位不就什么都没有了啊
      

  6.   

    外面再加一层nvl就是了
    NVL(LTRIM(STR,'0'),'0')
      

  7.   


    with t as
     (select '金海湾B区11-1702' str
        from dual
      union all
      select '金海湾B区11-1-1702' str
        from dual)
    select regexp_substr(str, '[^0-9]+') a,
           regexp_substr(str, '[0-9]+') b,
           decode(regexp_instr(str, '-', 1, 2),
                  0,
                  '0',
                  regexp_substr(str, '[0-9]+', 1, 2)) c,
           
           regexp_substr(str, '[0-9]+$') d
      from t;
      

  8.   

    写成存储过程的话,将获得的这些数据update到原表中,该怎么写啊
      

  9.   


    with t as
     (select '金海湾B区11-1702' str
        from dual
      union all
      select '金海湾B区11-1-1702' str
        from dual)
    select regexp_substr(str, '[^0-9]+') a,
           regexp_substr(str, '[0-9]+') b,
           decode(regexp_instr(str, '-', 1, 2),
                  0,
                  '0',
                  regexp_substr(str, '[0-9]+', 1, 2)) c,
           
           regexp_substr(str, '[0-9]+$') d
      from t;
    写成存储过程,将获得的这些数据update到原表中,该怎么写啊 
      

  10.   

    你是一点不会呗
    update T
    SET A=regexp_substr(str, '[^0-9]+'),
    B=regexp_substr(str, '[0-9]+'),
    C=decode(regexp_instr(str, '-', 1, 2),
                  0,
                  '0',
                  regexp_substr(str, '[0-9]+', 1, 2)),
    D= regexp_substr(str, '[0-9]+$');