Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2006
    Posts
    10

    Unanswered: Select statement problem in DB2

    Can anyone help me to change this Oracle statement to DB2 ?

    The statement is

    Select * from TableA where (ColA, ColB) IN (('Result1A','Resutl1B'),('Result2A','Result2B'));

    thanks for help !!

  2. #2
    Join Date
    May 2006
    Posts
    3

    Wink

    try that :

    SELECT * FROM SCHEMA.TableA
    WHERE (ColA, ColB) = ('Result1A','Resutl1B') OR (ColA, ColB) = ('Result2A','Result2B') OR ...etc.

  3. #3
    Join Date
    Apr 2006
    Posts
    10
    Thanks, but is that DB2 cannot use the syntax " IN (('Result1A','Resutl1B'),('Result2A','Result2B')) " ?

    It was because I use program to call this statement with Oracle enironment and "(('Result1A','Resutl1B'),('Result2A','Result2B')) " is put in the string, that mean
    a function do this:
    string_result = (dynamic get the result set e.g "('Result1A','Resutl1B'),('Result2A','Result2B ') ( ...).......or many many")

    and then call this statement
    Select * from TableA where (ColA, ColB) IN (string_result);

    It is difficult to extract each set of result and put in the statement with "OR".

    But I need to convert this function with DB2 environment.

  4. #4
    Join Date
    May 2006
    Posts
    3

    Wink

    ok! that's right :

    SELECT * FROM SCHEMA.TableA
    WHERE (ColA, ColB) IN (values ('Result1A','Resutl1B'),('Result2A','Result2B'))

  5. #5
    Join Date
    Apr 2006
    Posts
    10
    Many many thanks !! That works ! But why I can't find in any document?

  6. #6
    Join Date
    May 2006
    Posts
    3

    Wink

    thanks you for interest question!!!

    there are not direct reference to that construction, but

    predicate <IN> may refer to query and query may be emulated by <VALUES> construction

  7. #7
    Join Date
    Apr 2006
    Posts
    10
    oh...i c....thanks again for reply my stupid question

Posting Permissions

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