Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2004
    Posts
    1

    Unanswered: SQL0132N A LIKE predicate...

    Hello,

    I got the following query but encounter an exception.

    This is the query we have
    ==================================================
    SELECT varchar_column_a FROM table_a, table_b
    WHERE varchar_column_a LIKE
    '% ' || CAST(CAST(int_column_b AS CHAR(10)) AS VARCHAR(10)) || ' %'
    ==================================================

    As the name stated, what I want to do is to cast an int column as
    varchar and act as a string in the LIKE clause.

    Follow is the exception throw
    ==================================================
    SQL0132N A LIKE predicate or POSSTR scalar function is not valid
    because the first operand is not a string expression or the second
    operand is not a string. SQLSTATE=42824
    ==================================================

    Would any pls give me a help on it? Many thanks.

    Regards,
    kfchu

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Try this:

    SELECT varchar_column_a FROM table_a, table_b
    WHERE varchar_column_a LIKE
    '% ' || rtrim(varchar(char(int_column_b),10)) || ' %'

    Andy

  3. #3
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    pattern-expression
    An expression that specifies the string that is to be matched.
    The expression can be specified by any one of:
    - a constant
    - a special register
    - a host variable
    - a scalar function whose operands are any of the above
    - an expression concatenating any of the above
    So, it doesn't look like you can use "int_column_b" there.

Posting Permissions

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