Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6226557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:03:15+00:00 2026-05-24T09:03:15+00:00

I think I have a complex requirement. It’s a combinatorial permutation using Oracle 10.2,

  • 0

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 some improvements to made it simplest and more flexible.

Main behaviour.

input string: ‘one two’

output:
‘one’
‘two’
‘one two’
‘two one’

For my solution I’ve restricted the number of strings to 5 (note that the output is a number near the factorial)

SQL:

with My_Input_String as (select 1 as str_id, 'alpha beta omega gama' as str from dual )

--------logic-------

, String_Parse as (
                    SELECT REGEXP_SUBSTR(str, '[^ ]+', 1, ROWNUM) str
                    FROM My_Input_String
                    where rownum < 6 -- string limitation --
                    CONNECT BY level <= LENGTH(REGEXP_REPLACE(str, '([^ ])+|.', '\1') ) 
                  )    

--------CRAP select need refactoring-------

select str from String_Parse
union
select  REGEXP_REPLACE(trim(s1.str||' '||s2.str||' '||s3.str||' '||s4.str||' '||s5.str), '( ){2,}', ' ') as str
from 

(select str from String_Parse union select ' ' from dual) s1,
(select str from String_Parse union select '  ' from dual) s2,
(select str from String_Parse union select '   ' from dual) s3,
(select str from String_Parse union select '    ' from dual) s4,
(select str from String_Parse union select '     ' from dual) s5
where 
--
s1.str <> s2.str and s1.str <> s3.str and s1.str <> s4.str and s1.str <> s5.str
--
and s2.str <> s3.str and s2.str <> s4.str and s2.str <> s5.str
--
and s3.str <> s4.str and s3.str <> s5.str
--
and s4.str <> s5.str
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:03:16+00:00Added an answer on May 24, 2026 at 9:03 am

    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
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a complex graph of XML-serializable classes that I'm able to (de)serialize to
Hopefully this is less complex than I think. I have one table of companies,
I think I have a solution to this, but is there a better way,
I think I have a problem in understanding the proper way of using MVC.
I think I have a basic understanding of REST, but something I'm stuck on
I have done everything that is on the web (i think) i have the
I have set up a Django application that uses images. I think I have
This follows a couple of other questions (but I think I have refined my
I think the title speaks for itself. I have a complex query with a
If you have a complex requirement set with many users(&servers) how will your websocket

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.