View previous topic :: View next topic |
Author |
Message |
kingo Intermediate
Joined: 01 Sep 2006 Posts: 167 Topics: 40 Location: chennai
|
Posted: Tue May 12, 2009 1:46 am Post subject: Host variable issue |
|
|
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 |
|
|
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue May 12, 2009 4:59 am Post subject: |
|
|
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 |
|
|
kingo Intermediate
Joined: 01 Sep 2006 Posts: 167 Topics: 40 Location: chennai
|
Posted: Tue May 12, 2009 5:25 am Post subject: |
|
|
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 |
|
|
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue May 12, 2009 6:14 am Post subject: |
|
|
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 |
|
|
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue May 12, 2009 6:20 am Post subject: |
|
|
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 |
|
|
kingo Intermediate
Joined: 01 Sep 2006 Posts: 167 Topics: 40 Location: chennai
|
Posted: Tue May 12, 2009 6:33 am Post subject: |
|
|
Hi,
I had given those options but still the same issue.
And dynamic was just I tried to give an example _________________ IF YOU ARE NOT FOCUSSED ON GOAL ALL YOU SEE IS OBSTACLE. |
|
Back to top |
|
|
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue May 12, 2009 7:46 am Post subject: |
|
|
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 |
|
|
kingo Intermediate
Joined: 01 Sep 2006 Posts: 167 Topics: 40 Location: chennai
|
Posted: Tue May 12, 2009 8:30 am Post subject: |
|
|
Can you please explain?I didnt undertand your last reply.
Sorry about that . _________________ IF YOU ARE NOT FOCUSSED ON GOAL ALL YOU SEE IS OBSTACLE. |
|
Back to top |
|
|
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue May 12, 2009 9:24 am Post subject: |
|
|
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 |
|
|
kingo Intermediate
Joined: 01 Sep 2006 Posts: 167 Topics: 40 Location: chennai
|
Posted: Tue May 12, 2009 10:00 am Post subject: |
|
|
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 |
|
|
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue May 12, 2009 10:22 am Post subject: |
|
|
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 |
|
|
kingo Intermediate
Joined: 01 Sep 2006 Posts: 167 Topics: 40 Location: chennai
|
Posted: Tue May 12, 2009 10:28 am Post subject: |
|
|
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 |
|
|
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue May 12, 2009 11:38 am Post subject: |
|
|
got it, thx _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
|
|
|