View previous topic :: View next topic |
Author |
Message |
SHREER783 Beginner
Joined: 10 Oct 2006 Posts: 3 Topics: 2
|
Posted: Wed Dec 27, 2006 7:46 pm Post subject: Using LIKE predicate in COBOL pgm |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Thu Dec 28, 2006 7:21 am Post subject: |
|
|
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 |
|
 |
SHREER783 Beginner
Joined: 10 Oct 2006 Posts: 3 Topics: 2
|
Posted: Thu Dec 28, 2006 6:25 pm Post subject: |
|
|
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 |
|
 |
KIMOSABEE Beginner

Joined: 03 Apr 2006 Posts: 2 Topics: 0 Location: Alamo, TX
|
Posted: Tue Jan 02, 2007 5:52 pm Post subject: |
|
|
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 |
|
 |
|
|