MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using LIKE predicate in COBOL pgm

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
SHREER783
Beginner


Joined: 10 Oct 2006
Posts: 3
Topics: 2

PostPosted: Wed Dec 27, 2006 7:46 pm    Post subject: Using LIKE predicate in COBOL pgm Reply with quote

I am using a cursor to retrieve EMP_NUM from CSSXXX table
Code:

DECLARE EMP_NAME_CSR CURSOR FOR                   
 SELECT T609.TAB_ENT_NUM                     
   FROM CSSXXX_TAB_ENTRY   T609                   
       ,CSSYYY_CUST_ACCT   T128                   
 WHERE T609.TABLE_ABBRV_CODE      = 'CUST'       
   AND T609.PROENT_VALUE_TEXT     LIKE %WS-CUST-NAME%   
   AND T609.PROATR_ID             = 'MINCUST'   
   AND T609.PROENT_END_DATE       IS NULL             
   AND T609.TAB_ENT_NUM           = T128.CUST_NUM
 OPTIMIZE FOR 50 ROWS                               
END-EXEC.

The above query runs good in SPUFI but give sqlcode of 100 when executing the program. WS-CUST-NAME is 30 characters long.

Any idea why this query is not working in the cobol program?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Dec 28, 2006 7:21 am    Post subject: Reply with quote

SHREER783,

You need to put the % character after the last space of the value. You defined the host variable as character of 30. So if you move 'SHREER783' , it only occupies 9 bytes. So you need to put the % in the 10th byte.

Code:

MOVE 'SHREER783%'  TO  WS-CUST-NAME


If you want to search for SHREER783 string anywhere then

Code:

MOVE '%SHREER783%'  TO  WS-CUST-NAME



Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
SHREER783
Beginner


Joined: 10 Oct 2006
Posts: 3
Topics: 2

PostPosted: Thu Dec 28, 2006 6:25 pm    Post subject: Reply with quote

Hi,
The problem apparently lies in the search string WS-REP-N
I am building this variable WS-REP-N as follows:
STRING '%' WS-REP-NAME '%'
DELIMITED BY SIZE
INTO WS-REP-N.
Now, WS-REP-NAME being 30 char long, the string appears as
%NASH %

How do I build this string as %NASH%
In other words, string should be %ws-rep-name%

Please advise
Back to top
View user's profile Send private message
KIMOSABEE
Beginner


Joined: 03 Apr 2006
Posts: 2
Topics: 0
Location: Alamo, TX

PostPosted: Tue Jan 02, 2007 5:52 pm    Post subject: Reply with quote

Hi Shreer,
try building the following:
Code:

----------
       01  STRG-COUNTER PIC 99 VALUE ZEROES.
       01  WS-REP-N.
           05  WS-REP-1 PIC X(01) VALUE '%'.
           05  WS-REP-2 PIC X(29) VALUE SPACES.

----------
MOVE SPACES TO WS-REP-N.                   
ADD 1 TO STRG-COUNTER.   
STRING NAME DELIMITED BY '%'   
INTO WS-REP-2 POINTER STRG-COUNTER.         
----------
Now WS-REP-N should look like '%name%'.
Move it to WS-CUST-NAME and your statement should be revised to
     LIKE WS-CUST-NAME instead of
     LIKE %WS-CUST-NAME%

Hope this helps. Good Luck.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group