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
 

 

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
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts COBOL Programming Sandpit? jodrisco COBOL Programming 6 Wed Apr 12, 2017 3:47 am


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