Results 1 to 3 of 3

Thread: type conversion

  1. #1
    Join Date
    Jan 2005
    Posts
    80

    Unanswered: type conversion

    Hi ,

    Can any one tell me how to convert varchar to integer in the sub query.

    i have tried the below code and it's not working.

    Code:
    select * from Table1 where COL1 NOT IN (SELECT COL2 AS INTEGER FROM Table2 WHERE CODE_CATG_N='XXXX')
    col1 is smallint and col2 is varchar
    the error it is giving is

    SQL0401N The data types of the operands for the operation "IN" are not

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    That would be CAST() or INTEGER(), not "COL2 AS INTEGER".
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    The current syntax doesn't trigger a syntax error because "COL2 AS INTEGER" is allowed - it just renames the column from COL2 to the name INTEGER.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

Posting Permissions

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