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 

Host variable issue

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


Joined: 01 Sep 2006
Posts: 167
Topics: 40
Location: chennai

PostPosted: Tue May 12, 2009 1:46 am    Post subject: Host variable issue Reply with quote

Hi,

There is a DB2 cobol program which works fine in the sense it was able to fetch values when used hard coded values instead of host variables.

We changed the default compiler parm to pick APOSTSQL but we are not able fetch any rows through the query which was the same result when APOST was used.

Can any one guide me what should have went wrong?

This wasnt working

Code:



STRIP(CHAR(DAY(A.RCRD_DT)),T,' ') = :WS-FILE-REC-DT  AND   
STRIP(CHAR(DAY(A.PAY_DT)),T,' ')  = :WS-FILE-PAY-DT  AND   

where the host variables are X(2)




This was working

Code:



STRIP(CHAR(DAY(A.RCRD_DT)),T,' ') = '10'  AND   
STRIP(CHAR(DAY(A.PAY_DT)),T,' ')  = '25'  AND




Thanks
_________________
IF YOU ARE NOT FOCUSSED ON GOAL ALL YOU SEE IS OBSTACLE.
Back to top
View user's profile Send private message Yahoo Messenger
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Tue May 12, 2009 4:59 am    Post subject: Reply with quote

Quote:
where the host variables are X(2)


cut & paste the complete data division (or linkage div) definition.
if there are no VALUE clauses, post the code that populates the fields
and
give us the results of
Code:
LENGTH(STRIP(CHAR(DAY(A.RCRD_DT)),T,' '))

_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
kingo
Intermediate


Joined: 01 Sep 2006
Posts: 167
Topics: 40
Location: chennai

PostPosted: Tue May 12, 2009 5:25 am    Post subject: Reply with quote

Result of code
LENGTH(STRIP(CHAR(DAY(A.RCRD_DT)),T,' '))

is 2

Data Definition :

01 WS-FILE-REC-DT PIC X(02).

01 WS-FILE-PAY-DT PIC X(02).


Code Movement

MOVE '10' TO WS-FILE-REC-DT
MOVE '25' TO WS-FILE-PAY-DT

We can not give the value in PIC clause as the Value will be dynamic.
_________________
IF YOU ARE NOT FOCUSSED ON GOAL ALL YOU SEE IS OBSTACLE.
Back to top
View user's profile Send private message Yahoo Messenger
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Tue May 12, 2009 6:14 am    Post subject: Reply with quote

Kingo,

please!
Quote:

Code Movement

MOVE '10' TO WS-FILE-REC-DT
MOVE '25' TO WS-FILE-PAY-DT


that is not dynamic.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Tue May 12, 2009 6:20 am    Post subject: Reply with quote

For example, suppose that you want to process SQL statements as you compile a COBOL program. In your program, the apostrophe is the string delimiter in SQL statements, and the SQL statements conform to DB2 rules. This means that you need to specify the APOSTSQL and STDSQL(NO) options. Therefore, you need to include this option in your compile step:

SQL("APOSTSQL STDSQL(NO)")
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
kingo
Intermediate


Joined: 01 Sep 2006
Posts: 167
Topics: 40
Location: chennai

PostPosted: Tue May 12, 2009 6:33 am    Post subject: Reply with quote

Hi,

I had given those options but still the same issue.

And dynamic was just I tried to give an example Embarassed
_________________
IF YOU ARE NOT FOCUSSED ON GOAL ALL YOU SEE IS OBSTACLE.
Back to top
View user's profile Send private message Yahoo Messenger
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Tue May 12, 2009 7:46 am    Post subject: Reply with quote

you do realize that when you strip days 1 thru 9, you are left with a 1 char column result.

are you having problems when the host variable is > 9?
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
kingo
Intermediate


Joined: 01 Sep 2006
Posts: 167
Topics: 40
Location: chennai

PostPosted: Tue May 12, 2009 8:30 am    Post subject: Reply with quote

Can you please explain?I didnt undertand your last reply.

Sorry about that Embarassed .
_________________
IF YOU ARE NOT FOCUSSED ON GOAL ALL YOU SEE IS OBSTACLE.
Back to top
View user's profile Send private message Yahoo Messenger
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Tue May 12, 2009 9:24 am    Post subject: Reply with quote

forget the strip(char stuff.

DAY returns an integer.
change your sql to
WHERE DAY(A.RCRD_DT) = :WS-DAY

where ws-day is defined as:
WS-DAY PIC S9(9) COMP.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
kingo
Intermediate


Joined: 01 Sep 2006
Posts: 167
Topics: 40
Location: chennai

PostPosted: Tue May 12, 2009 10:00 am    Post subject: Reply with quote

Thanks Dick I had found the problem and where I went wrong was initatialised after opening cursor which was wrong.

I figured it out and made changes and it went fine.

Thanks for your ample patience.
_________________
IF YOU ARE NOT FOCUSSED ON GOAL ALL YOU SEE IS OBSTACLE.
Back to top
View user's profile Send private message Yahoo Messenger
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Tue May 12, 2009 10:22 am    Post subject: Reply with quote

glad that it is working.

when you have time, could you tell me what you did to correct the problem.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
kingo
Intermediate


Joined: 01 Sep 2006
Posts: 167
Topics: 40
Location: chennai

PostPosted: Tue May 12, 2009 10:28 am    Post subject: Reply with quote

Sure

I moved these statements before open

MOVE '10' TO WS-FILE-REC-DT
MOVE '25' TO WS-FILE-PAY-DT

And it worked fine.
_________________
IF YOU ARE NOT FOCUSSED ON GOAL ALL YOU SEE IS OBSTACLE.
Back to top
View user's profile Send private message Yahoo Messenger
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Tue May 12, 2009 11:38 am    Post subject: Reply with quote

got it, thx
_________________
Dick Brenholtz
American living in Varel, Germany
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 -> 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