Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2008
    Posts
    26

    Question Unanswered: how to use a comma separated string in a "IN clause" in oracle

    hi,

    i m passing a comma separated string in my procedure i want to use it in my "IN clause" but i need to convert it in aparticular format to use in my in clause. can u give me a solution for it???????????

    example
    my variable is v_string='a,b,c,d'

    select * from m_tab where menuid in ('a','b','c','d')

    how shud i convert it in this format
    'a','b','c','d' to use in my "IN clause"

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    REPLACE might be one way to do that:
    Code:
    SQL> select '''' || replace('a,b,c,d', ',', ''',''') || '''' result from dual;
    
    RESULT
    ---------------
    'a','b','c','d'
    
    SQL>
    Although, you might want to visit Ask Tom site and search for "varying elements in IN list".

Posting Permissions

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