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 

Problemwith host variable in SQL

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


Joined: 10 Dec 2002
Posts: 46
Topics: 20
Location: Providence, RI

PostPosted: Tue Nov 11, 2003 11:55 am    Post subject: Problemwith host variable in SQL Reply with quote

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
View user's profile Send private message
help_me
Beginner


Joined: 03 Oct 2003
Posts: 11
Topics: 4

PostPosted: Tue Nov 11, 2003 1:37 pm    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Tue Nov 11, 2003 6:39 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
gore
Beginner


Joined: 10 Dec 2002
Posts: 46
Topics: 20
Location: Providence, RI

PostPosted: Wed Nov 19, 2003 10:32 am    Post subject: Reply with quote

Thanks everyone, the problem was due to movement of spaces to host varible just before opening the cursor.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database 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