If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > SQL0132N A LIKE predicate...

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-06-04, 02:20
chusir chusir is offline
Registered User
 
Join Date: Jul 2004
Posts: 1
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
Reply With Quote
  #2 (permalink)  
Old 08-06-04, 08:33
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Try this:

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

Andy
Reply With Quote
  #3 (permalink)  
Old 08-06-04, 12:13
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On