Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2007
    Posts
    63

    Question Unanswered: String function "IN" with dynamic arguments

    can you suggest of the ways for me to do string existence check against a table field

    eg:

    sal_type IN ( 'S','R',...<dynamic list>)

    the number of arguments in the parenthesis is not fixed and may vary at run time

    i.e. if the sal_type matches with any of the listed characters, then --> output stmts

    any quick suggestion would be really helpful

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    You have two choices. Build the SQL statement dynamically and set the entire list by appending the items on. This can get ugly. Second, Put the values in a temp table and then use "where x in (select y from temptable)".

    Andy

  3. #3
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    > sal_type IN ( 'S','R',...<dynamic list>)
    LOCATE(sal_type, 'S,R,' || <dynamic list>) > 0

  4. #4
    Join Date
    May 2007
    Location
    somewhere in dbforums
    Posts
    221
    It also depends upon from where you are getting your dynamic list from....
    If you can get it from the DB itself you can very well use a sub-query
    OR
    If you are getting it from application OR if you are getting it from application + DB then you can very well try out dynamic SQL statements. (All that you do in this case is store the SQL statement in a VARCHAR and then execute the same)

  5. #5
    Join Date
    Apr 2007
    Posts
    63

    Thumbs up

    yes. thank u so much. I am done with my processing with these helpful suggestions!

Posting Permissions

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