View previous topic :: View next topic
|
Author |
Message |
Balaryan Warnings : 2 New User
Joined: 20 Nov 2009 Posts: 27 Location: chennai
|
|
|
|
Hi All,
I am novice and very new to easytrive. I am facing an issue while compiling the easytrive program and getting couple of B204 errors. I am trying to access DB2 table using cursor and writing the corresponding fields in the report.
DB2 table referred having couple of COMP fields. I attached the table layout and the program log information with the error listed. It would be great if anyone can correct me where exactly I do mistake.
Appreciate your time and help. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
do not post attachments... not everybody can see them. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
You can find it in the manual(s).
CA-Easytrieve/Plus Reference Guide |
|
Back to top |
|
|
Balaryan Warnings : 2 New User
Joined: 20 Nov 2009 Posts: 27 Location: chennai
|
|
|
|
Thanks for the info, Enrico.
I will provide the necessary details here. Record layout of the table with fixed length is 204 listed below.
Code: |
SEQ LVL FIELD NAME FORMAT START LENGTH
********************************** TOP OF DATA ********************************
1 01 DCLLOC-CLASS-GROUP G 1 204
2 10 CPN-LOC-GRP-ID B 9 1 4
3 10 CPN-LOC-GRP-CLASS C 50 5 50
4 10 CPN-LOC-GRP-NAME C 50 55 50
5 10 CPN-STR-NAME C 50 105 50
6 10 CPN-STR-NBR B 9 155 4
7 10 CPN-START-DTE C 10 159 10
8 10 CPN-END-DTE C 10 169 10
9 10 CPN-LOC-TIMESTAMP C 26 179 26
|
In my program, I defined the binary fields CPN-LOC-GRP-ID and CPN-STR-NBR as numeric for readability. If I define with Binary type in my easytrieve program, I am getting the following errors
“*******B097 LENGTH INVALID FOR TYPE – B” for both binary fields
“*******B082 NAME IS UNDEFINED - W-FIELD-01”
“*******B082 NAME IS UNDEFINED - W-FIELD-05”
So I changed the corresponding fields to Numeric type for displaying the values in the report.
I am getting the bunch of B204 errors after compiling my EZT program.
Code: |
*******B204 SQL - INVALID HOSTVAR DATATYPE 836
*******B204 SQL - CURSOR CUR001 NOT REFERENCED IN AN SQL "FETCH" COMMAND
*******B204 SQL - KEYWORD IN ERROR: CUR001
*******B204 SQL - SQL ERRORS FOUND
|
I am referring the CUR001 in my FETCH statement. But still it points error message in that section. I have no clue.
I am listing my program log information for reference.
Code: |
*
FILE EXTRACT
W-FINAL-REC 1 198 A
*
*---------------------------------------------------------------------*
* STORAGE *
*---------------------------------------------------------------------*
W-OUT-REC W 198 A
W-FIELD-01 W-OUT-REC 09 N
W-FILLER-1 W-OUT-REC +09 01 A
W-FIELD-02 W-OUT-REC +10 50 A
W-FILLER-2 W-OUT-REC +60 01 A
W-FIELD-03 W-OUT-REC +61 50 A
W-FILLER-3 W-OUT-REC +111 01 A
W-FIELD-04 W-OUT-REC +112 50 A
W-FILLER-4 W-OUT-REC +162 01 A
W-FIELD-05 W-OUT-REC +163 09 N
W-FILLER-5 W-OUT-REC +172 01 A
W-FIELD-06 W-OUT-REC +173 10 A
W-FILLER-6 W-OUT-REC +183 01 A
W-FIELD-07 W-OUT-REC +184 10 A
WS-SQLCODE W 5 N VALUE 0 MASK ('----9')
**********************************************************************
* *
* INVOKING THE DB2 - LOC_CLASS_GROUP BY DECLARING CURSOR *
* ---------------------------------------------------------- *
*
+
SQL DECLARE CUR001 CURSOR FOR +
SELECT LCG.CPN_LOC_GRP_ID, +
LCG.CPN_LOC_GRP_CLASS, +
LCG.CPN_LOC_GRP_NAME, +
LCG.CPN_STR_NAME, +
LCG.CPN_STR_NBR, +
LCG.CPN_START_DTE, +
LCG.CPN_END_DTE +
FROM TRLRR.LOC_CLASS_GROUP LCG +
ORDER BY LCG.CPN_LOC_GRP_ID +
WITH UR
*
*---------------------------------------------------------------------*
* MAIN *
*---------------------------------------------------------------------*
JOB INPUT NULL
DISPLAY ' PROGRAM BEGIN !!!'
*
** OPEN THE DB2 FILE CURSOR
*
*
IF SQLCODE NE 0
WS-SQLCODE = SQLCODE
PERFORM OPEN-FAILED
END-IF
*
PERFORM FETCH-CURS1
* CLOSE THE DB2 FILE CURSOR.
SQL CLOSE CUR001
IF SQLCODE NE 0
WS-SQLCODE = SQLCODE
PERFORM CLOSE-FAILED
END-IF
*
*----------------------------------------------------------------*
* F E T C H - CURS1 P R O C E D U R E *
*----------------------------------------------------------------*
FETCH-CURS1. PROC
PERFORM INITIALIZE-FIELDS
SQL FETCH CUR001 INTO +
:W-FIELD-01 +
,:W-FIELD-02 +
,:W-FIELD-03 +
,:W-FIELD-04 +
,:W-FIELD-05 +
,:W-FIELD-06 +
,:W-FIELD-07
*******B204 SQL - INVALID HOSTVAR DATATYPE 836
W-FINAL-REC = W-OUT-REC
DISPLAY W-FIELD-01
PUT EXTRACT
IF SQLCODE NE 0
WS-SQLCODE = SQLCODE
PERFORM FETCH-FAILED
END-IF
*
END-PROC
*
***********************************************************************
INITIALIZE-FIELDS. PROC
***********************************************************************
W-FILLER-1 = ';'
W-FILLER-2 = ';'
W-FILLER-3 = ';'
W-FILLER-4 = ';'
W-FILLER-5 = ';'
W-FILLER-6 = ';'
W-FIELD-01 = 0
W-FIELD-02 = ' '
W-FIELD-03 = ' '
W-FIELD-04 = ' '
W-FIELD-05 = 0
W-FIELD-06 = ' '
W-FIELD-07 = ' '
*
END-PROC
*----------------------------------------------------------------*
*
*---------------------------------------------------------------------*
* O P E N - F A I L E D P R O C E D U R E
*---------------------------------------------------------------------*
*
OPEN-FAILED. PROC
DISPLAY '**************************************'
DISPLAY ' PROGRAM SAMPLE01 ABEND '
DISPLAY ' UNABLE TO OPEN CURSOR CURS1 '
DISPLAY ' SQLCODE = ' WS-SQLCODE
DISPLAY '**************************************'
RETURN-CODE = +3802
STOP
END-PROC
*----------------------------------------------------------------*
* F E T C H - F A I L E D P R O C E D U R E *
*----------------------------------------------------------------*
FETCH-FAILED. PROC
DISPLAY '**************************************'
DISPLAY ' PROGRAM SAMPLE01 ABEND '
DISPLAY ' UNABLE TO FETCH CURSOR CUSR1 '
DISPLAY ' SQLCODE = ' WS-SQLCODE
DISPLAY '**************************************'
RETURN-CODE = +3804
STOP
END-PROC
*
*----------------------------------------------------------------*
* C L O S E - F A I L E D P R O C E D U R E *
*----------------------------------------------------------------*
CLOSE-FAILED. PROC
DISPLAY '**************************************'
DISPLAY ' PROGRAM SAMPLE01 ABEND '
DISPLAY ' UNABLE TO CLOSE CURSOR CURS1 '
DISPLAY ' SQLCODE = ' WS-SQLCODE
DISPLAY '**************************************'
RETURN-CODE = +3806
STOP
END-PROC
*---------------------------------------------------------------------*
*******B204 SQL - CURSOR CUR001 NOT REFERENCED IN AN SQL "FETCH" COMMAND
*******B204 SQL - KEYWORD IN ERROR: CUR001
*******B204 SQL - SQL ERRORS FOUND
*******A014 PREMATURE TERMINATION DUE TO PREVIOUS ERROR(S)
|
|
|
Back to top |
|
|
Balaryan Warnings : 2 New User
Joined: 20 Nov 2009 Posts: 27 Location: chennai
|
|
|
|
Hi Peter,
I could not find one in CA Easytrieve reference guide 6.2. If possible, can you provide some insight to this error and I have no clue why it display error "B204 SQL - CURSOR CUR001 NOT REFERENCED IN AN SQL "FETCH" COMMAND" when I refer my declared cursor CUR001 in my FETCH cmd. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
And yet you did NOT show use the code with the binary variable that is not working, but rather showed us a bunch of code that is irrelevant.
A binary variable length is 2 or 4 or 8 -- and that is all that is allowed in Easytrieve. Since you got the B097 error, I'm guessing you did NOT specify 2 or 4 or 8 for your binary variable length.
The B204 is due to the invalid host variable you specified in the FETCH. Since the FETCH was invalid, the cursor isn't referenced by any other valid SQL statements and hence B204. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3053 Location: NYC,USA
|
|
|
|
Double check the variable declaration. And should have posted this to Beginner's forum instead as that is meant to be for novice. |
|
Back to top |
|
|
Balaryan Warnings : 2 New User
Joined: 20 Nov 2009 Posts: 27 Location: chennai
|
|
|
|
Robert,
Thanks for the info. It helps. I used type/length (B 4) for my fields CPN-LOC-GRP-ID and CPN-STR-NBR respectively. then it complied fine.
I am using the same piece of codes where i changed the format from B to N for fields CPN-LOC-GRP-ID and CPN-STR-NBR which was not compatible with DB2 fields.
When I run this program, I got an output with binary field displaying as "1,347,376". But expected output should be 1347376.
In this case, can I use MASK (99999999) during field declaration?
Kindly advice. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
When I run this program, I got an output with binary field displaying as "1,347,376". But expected output should be 1347376.
In this case, can I use MASK (99999999) during field declaration? |
Why not just try it instead of posting to a forum? If it works, you'll know and if it doesn't work you'll know - in which case you create another work variable with the mask and move the host variable to it. I am by no means an Easytrieve expert -- I've used it here and there down through the years, but the last site I worked at that had it installed was about 1989 or so (maybe 1998?). I know data and I can Google manuals, which is how I answered the previous question. |
|
Back to top |
|
|
|