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: 1278
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. Full Time COBOL Software Development ... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:24 am
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am
No new posts Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm


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