Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
usage of strip function in cobol embedded query

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

New User


Joined: 07 Oct 2008
Posts: 23
Location: Chennai

PostPosted: Mon Dec 27, 2010 3:11 pm    Post subject: usage of strip function in cobol embedded query
Reply with quote

I used strip function in QMF and it works and in cobol program the same query is not working.

Will Cobol support this scalar function ?
Here is my query, Please help

ws-variable pic x(3).

EXEC SQL
select *
from tablename
where
strip(field_name1) like : ws-variable
END-EXEC

When ws-variable holds the value of 3 bytes, it works fine. when a two byte value is passed to this variable, it fails. ( I have used LIKE because i want to use it as a search function, if ws-variable is spaces '%%%' will be passed for search to pick all the data in the cobol program, if ws-variable is not spaces, the exact value has to be searched. )

Thanks.
Back to top
View user's profile Send private message

singhju

New User


Joined: 01 Dec 2010
Posts: 25
Location: Gurgaon

PostPosted: Mon Dec 27, 2010 4:34 pm    Post subject:
Reply with quote

What is field_name1? Shouldn't you strip the :ws-variable instead fo column?
Please make your requirement more clear.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Dec 27, 2010 10:19 pm    Post subject:
Reply with quote

Hello,

What is the value in :ws-variable?
Back to top
View user's profile Send private message
erhema

New User


Joined: 07 Oct 2008
Posts: 23
Location: Chennai

PostPosted: Tue Dec 28, 2010 3:13 pm    Post subject:
Reply with quote

Hi,

I got the result by using the below query (using STRIP on both sides)

EXEC SQL
select *
from tablename
where
strip(field_name1) like strip( :ws-variable )
END-EXEC


My Previous query worked for the value of ws-variable 'ABC' etc.. (i.e of 3 bytes), but it failed for 'AB' or 'CD' (any value that is less than 3 bytes).

Now, using STRIP on both sides, it is working for values less than or equal to 3.

Thanks for your reply.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Jan 05, 2011 3:23 pm    Post subject:
Reply with quote

ws-variable will always be 3 bytes , thus never 'AB' or 'CD' but 'AB ' or 'CD '
I'll assume that field_name1 is defined as char(3).
field_name1 can be 'AB ' or 'CD '
strip(field_name1) will then be 'AB' or 'CD'

'AB' like 'AB ' will return FALSE
'AB ' like 'AB ' will return TRUE
strip('AB ') like strip('AB ') will return TRUE

thus actually you should not use STRIP() anywhere. adding strip() will only make performance worse.

If field_name1 is a varchar then it is a different story. Then you should use a different definition for ws-variable.
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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us