View previous topic :: View next topic |
Author |
Message |
gore Beginner
Joined: 10 Dec 2002 Posts: 46 Topics: 20 Location: Providence, RI
|
Posted: Tue Nov 11, 2003 11:55 am Post subject: Problemwith host variable in SQL |
|
|
Hi
I am using a host variable in COBOL : V1 pic x(15) in which the following value has been moved '9999999999999 '. (2 trailing spaces.)
The same value exists in DB row also with trailing spaces.
When i use the following cursor
select * from table where search_field = :V1.
It is not able to retrive the row from the table and gives me SQL code of +100.
When I hardcode the same value in Cursor it fetches the row.
I am using the Move statement to populate the host variable.
Please note that both the table column and the variable from which host variable is populated are of same length pic x(15).
What could be the reason for its inability to find the match? Are the two trailing spaces being ignored in host variable?
Any pointers would be highly appreciated. |
|
Back to top |
|
|
help_me Beginner
Joined: 03 Oct 2003 Posts: 11 Topics: 4
|
Posted: Tue Nov 11, 2003 1:37 pm Post subject: |
|
|
Inspect for removing the SPACES before Opening the Cursor
EXEC SQL
SET :WS-VARV1 = STRIP(:V1)
END-EXEC.
And then Open the CURSOR
Hope this helps.
Rgds
Srinivas |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Tue Nov 11, 2003 6:39 pm Post subject: |
|
|
gore,
Are you pretty sure that the value in the table has indeed two trailing spaces in it. I suspect that you have binary zeroes in the last 2 bytes which will look like spaces. If you hex on then you should have a hex value x'40' in the last 2 bytes.
Kolusu |
|
Back to top |
|
|
gore Beginner
Joined: 10 Dec 2002 Posts: 46 Topics: 20 Location: Providence, RI
|
Posted: Wed Nov 19, 2003 10:32 am Post subject: |
|
|
Thanks everyone, the problem was due to movement of spaces to host varible just before opening the cursor. |
|
Back to top |
|
|
|
|