Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

SQL CODE -132. Issue with LIKE operator

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
GaganGarg

Active User


Joined: 31 Mar 2010
Posts: 132
Location: India

PostPosted: Wed Jan 30, 2013 3:22 pm    Post subject: SQL CODE -132. Issue with LIKE operator
Reply with quote

Hi,
I am trying to run the following query in SPUFI.

Code:

    SELECT TAB1.OUT_FLG                                           
      FROM DEVB.TAB2_DEPT     TAB2,                           
           DEVB.TAB1_PROD_TYP TAB1                             
           WHERE TAB2.UNIT_ID = 'ABD'                         
             AND TAB2.DEPT_ID = '01'                             
             AND TAB1.PROD_TYP_DSC LIKE                           
             CHAR('''%'||RTRIM(TAB2.DEPT_DSC)||'%''')       
     FETCH FIRST 1   ROW ONLY                                         
     WITH UR; 


It is giving the SQLCODE=-132 which says that "ERROR: AN OPERAND OF LIKE IS NOT VALID".

I tried to use concat function also instead of using the operator '||'. Does anybody having any idea what is wrong in the query? Any help is highly appreciated. Thanks.
Back to top
View user's profile Send private message

chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 269
Location: Mumbai

PostPosted: Wed Jan 30, 2013 4:56 pm    Post subject:
Reply with quote

Hi,

Its becuase DB2 will convert the the entire string to CHAR and then it will use for LIKE operation where it will not get the '% ' required for LIKE parameter

regards,
Chandan
Back to top
View user's profile Send private message
GaganGarg

Active User


Joined: 31 Mar 2010
Posts: 132
Location: India

PostPosted: Wed Jan 30, 2013 4:59 pm    Post subject:
Reply with quote

I have given CHAR after LIKE operator because TAB1.PROD_TYP_DSC column is having datatype CHAR. I could not get what you want to say.
I used CHAR('''%'||RTRIM(TAB2.DEPT_DSC)||'%''') in the select clause instead of using it in WHERE clause. There it is getting displayed as '%MEAT%' if the column TAB2.DEPT_DSC is having the value MEAT in the table TAB2. And, '%MEAT%' should be the value which can be used with LIKE operator. but i am getting SQLCODE=-132 when i use it in WHERE clause. .
Back to top
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 269
Location: Mumbai

PostPosted: Wed Jan 30, 2013 5:42 pm    Post subject:
Reply with quote

Here as you are getting '%MEAT%' as a result of CHAR function DB2 will consider '%MEAT%' as char entire string including '%'.
This % will not be considered as one which DB2 uses for LIKE operation.
Back to top
View user's profile Send private message
GaganGarg

Active User


Joined: 31 Mar 2010
Posts: 132
Location: India

PostPosted: Wed Jan 30, 2013 5:48 pm    Post subject:
Reply with quote

Ohk. Any other way to do the same in query?
Back to top
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 269
Location: Mumbai

PostPosted: Wed Jan 30, 2013 7:34 pm    Post subject:
Reply with quote

I am not sure but I think you cant use another DB2 column in LIKE parameter..

But let other people go through this post as they will be able to guide you correctly
Back to top
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 295
Location: Singapore

PostPosted: Thu Jan 31, 2013 4:51 pm    Post subject:
Reply with quote

You can try locate instead.
locate(TAB2.DEPT_DSC,TAB1.PROD_TYP_DSC) <> 0
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts PL/I code tuning/Performance improvement Virendra Shambharkar PL/I & Assembler 3 Mon Dec 05, 2016 11:57 am
No new posts What is the code in CLIST to enable t... jackzhang75 CLIST & REXX 1 Fri Dec 02, 2016 3:02 am
No new posts IDEAL - Code Retrieval yugendran CA Products 0 Fri Nov 25, 2016 3:27 pm
No new posts DFHRESPONSE returns issue divated CICS 3 Wed Nov 02, 2016 6:32 pm
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us