Breaking string
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Breaking string

  1. #1
    Join Date
    Jul 2002
    Posts
    132

    Breaking string

    Hi,

    Can someone help me out.
    I have a string like this abc#def#hij#klo coming in as a parameter.
    Now I need to break this string with delimiter as # and have them in the where condition like
    where col in ('abc','def','hij','klo')
    Pl. note that this string can have any number of sub-strings like this delimited by #.
    How do I do this?

    Regards
    Sonia

  2. #2
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    WHERE INSTR(input_string||'#', col||'#') <> 0
    should work, but won't be efficient (can't use an index on col).
    "The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman

  3. #3
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    WHERE INSTR('#'||input_string||'#', '#'||col||'#') <> 0
    would be even nicer - it should deal with variable length substrings.
    "The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width