gpt4 book ai didi

oracle 字符串转成行

转载 作者:qq735679552 更新时间:2022-09-29 22:32:09 28 4
gpt4 key购买 nike

CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.

这篇CFSDN的博客文章oracle 字符串转成行由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.

SELECT   SUBSTR (T.RPT_ID,                 INSTR (T.RPT_ID,',',1,C.LV)+ 1,                 INSTR (T.RPT_ID,',',1,C.LV + 1)- (INSTR (T.RPT_ID,',',1,C.LV)+ 1))             AS RPT_ID   FROM   (SELECT ',' || '85,86,87' || ',' RPT_ID,                  LENGTH ('85,86,87' || ',') - NVL (LENGTH (REPLACE ('85,86', ',')), 0) CNT             FROM DUAL) t,          (SELECT LEVEL lv             FROM DUAL           CONNECT BY LEVEL <= LENGTH('85,86,87' || ',') - NVL(LENGTH(REPLACE('85,86,87', ',')), 0)) c  WHERE   T.cnt >= c.lv 说明:CNT表示串里面有多少字符。 当是字符串是表中的字段时,取level<=最大个数 如: 1).取最大个数 SELECT MAX(LENGTH(RPT_ID || ',') -             NVL(LENGTH(REPLACE(RPT_ID, ',')), 0)) INTO v_c     FROM DIM_AUDIT_TABLE@sjmh_inter; 2).l转成行 SELECT T.T_NAME,                        T.T_NAME_COMM,                        T.T_COLUMN,                        T.T_COLUMN_COMM,                        t.COMMENT_NL,                        t.COMMENT_NL_TIME,                        t.SEQ_USER_ID,                        SUBSTR(T.RPT_ID,                               INSTR(T.RPT_ID, '','', 1, C.LV) + 1,                               INSTR(T.RPT_ID, '','', 1, C.LV + 1) -                               (INSTR(T.RPT_ID, '','', 1, C.LV) + 1)) AS RPT_ID                   FROM (SELECT A.T_NAME,                                A.T_NAME_COMM,                                A.T_COLUMN,                                A.T_COLUMN_COMM,                                a.COMMENT_NL,                                a.COMMENT_NL_TIME,                                a.SEQ_USER_ID,                                '','' || A.RPT_ID || '','' RPT_ID,                                LENGTH(A.RPT_ID || '','') -                                NVL(LENGTH(REPLACE(A.RPT_ID, '','')), 0) CNT                           FROM DIM_AUDIT_TABLE@sjmh_inter A                          WHERE a.COMMENT_NL is not null) T,                        (SELECT LEVEL LV FROM DUAL CONNECT BY LEVEL <= '||v_c||') C                  WHERE C.LV <= T.CNT,

注:如果是上面代码是远程的代码,(SELECT LEVEL LV FROM DUAL CONNECT BY LEVEL <= '||v_c||') C,不要用dual表,可以改用all_objects或user_objects, 要不然能查询,但是把查询出来的SQL插入到某个表时,只能插入一行 。

最后此篇关于oracle 字符串转成行的文章就讲到这里了,如果你想了解更多关于oracle 字符串转成行的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com