Oracle - string combinatorial permutation

后端 未结 1 608
一个人的身影
一个人的身影 2021-01-05 13:28

I think I have a complex requirement.

It\'s a combinatorial permutation using Oracle 10.2, I\'was able to solve it using cartesian joins, but I think that it need so

相关标签:
1条回答
  • 2021-01-05 13:55

    Edit: Got the generic one. Really simple in the end (but took me a while to get there)

    WITH words AS
    (   SELECT  REGEXP_SUBSTR( '&txt', '\S+', 1, LEVEL )    AS word
            ,   LEVEL                                       AS num
        FROM    DUAL
        CONNECT BY LEVEL <= LENGTH( REGEXP_REPLACE( '&txt', '\S+\s*', 'X' ) )
    )
    SELECT  SYS_CONNECT_BY_PATH( W.word, ' ' )
    FROM    words   W
    CONNECT BY NOCYCLE PRIOR W.num != W.num
    

    Edit2: Removed redundant maxnum stuff. Left over from previous attempts

    0 讨论(0)
提交回复
热议问题