View previous topic :: View next topic
|
Author |
Message |
sasanka Warnings : 1 New User
Joined: 18 Jan 2008 Posts: 34 Location: India
|
|
|
|
Hi,
I am trying to compile a Cobol Db2 code which looks like below:
Cursor TST_CSR is declared as below:
Code: |
EXEC SQL
DECLARE TST_CSR CURSOR
WITH ROWSET POSITIONING FOR
SELECT SEC_NO
FROM TABSEC
WHERE TYPE_CD = 'CAD'
FOR READ ONLY WITH UR
END-EXEC. |
Above cursor TST_CSR is fetched as below:
Code: |
EXEC SQL
FETCH NEXT ROWSET FROM
TST_CSR
FOR 10 ROWS
INTO :WS-SEC-NO
END-EXEC. |
Working Storage variable WS-SEC-NO is declared as below:
Code: |
01 WS-CURSOR_DATA-HD.
05 WS-SEC-NO PIC X(5) OCCURS 3000 TIMES. |
Now, while compiling my program I got below error message:
IGYPS2120-S Expected a reference-modification specification but found ")". The "CALL" statement was discarded.
Code: |
PROCEDURE DIVISION. 03650
03730
DSNSQL SECTION.
SQL-SKIP.
GO TO SQL-INIT-END.
SQL-INITIAL.
MOVE 1 TO SQL-INIT-FLAG.
CALL 'DSNHADDR' USING SQL-CODEPTR OF SQL-PLIST3 SQLCA.
CALL 'DSNHADDR' USING SQL-VPARMPTR OF SQL-PLIST4 SQL-PVAR-LIS
T4.
CALL 'DSNHADD2' USING SQL-PVAR-ADDRS3 IN
SQL-PVAR-LIST4 WS-ROWSET-SIZE SQL-NULL
CALL 'DSNHADDR' USING SQL-APARMPTR OF SQL-PLIST4 SQL-AVAR-LIS
T4.
CALL 'DSNHADD2' USING SQL-AVAR-ADDRS1 IN
SQL-AVAR-LIST4(1) SQL-NULL.
IGYPS2120-S Expected a reference-modification specification but found ")". The "CALL" statement was discarded.
CALL 'DSNHADDR' USING SQL-CODEPTR OF SQL-PLIST5 SQLCA.
SQL-INIT-END.
CONTINUE. |
Please help me to resolve this error.
Thanks.
Code'd |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Is the cunningly-named SQL-AVAR-LIST4 part of an OCCURS? No. It's not. So when the compiler sees an opening bracket, it knows it can only be a reference-modification, and with that message the compiler is expressing its disappointment that no valid reference modification was found. |
|
Back to top |
|
|
sasanka Warnings : 1 New User
Joined: 18 Jan 2008 Posts: 34 Location: India
|
|
|
|
SQL-AVAR-LIST4 is automatically generated while I am trying to compile my code.
Please let me know what is wrong in my code for which I got above compiling error and how to solve it. |
|
Back to top |
|
|
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 765 Location: Whitby, ON, Canada
|
|
|
|
Were there any warning messages produced by the Precompile step? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
To do what I believe you want, you need to read the individual rows and store them in an array - one way or another. The array name cannot be used to receive the individual entries. |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
dick scherrer wrote: |
To do what I believe you want, you need to read the individual rows and store them in an array - one way or another. The array name cannot be used to receive the individual entries. |
Not true.
I don't see any mistake in the cobol/sql coding (besides a discrepancy between 10 rows and occurs 3000 , but that shouldn't be a problem)
I would check the output, version of the precompiler and if you don't find anything out of the ordinary : open a PMR with IBM. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hi Guy,
My reply was not worded so well and i may be completely off-base . . .
It was my understanding that to read an 'array" one used the multi-row fetch?
As coded, how will the array be incremented as single rows are fetched?
Check your PM please.
d |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
fetch rowset for 10 rows is a multi-row fetch (of 10 rows)
each execution will fill up WS-SEC-NO (1..10)
It does not mean that doing it 300 times will fill up the 3000-occ table, maybe that is the confusion. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Thanks for the correction/clarification.
i appreciate you keeping me straight
d |
|
Back to top |
|
|
sasanka Warnings : 1 New User
Joined: 18 Jan 2008 Posts: 34 Location: India
|
|
|
|
Hi,
Please find below precompiler details getting at the time of compilation
DB2 SQL PRECOMPILER VERSION 10 REL. 1.0
OPTIONS SPECIFIED: APOST,APOSTSQL,VERSION(AUTO),HOST(IBMCOB),NEWFUN(NO)
PP 5655-S71 IBM Enterprise COBOL for z/OS 4.2.0
Invocation parameters:
NOSEQ,MAP,LIST,
IGYOS4020-W The "OFFSET" option was discarded due to option
conflict resolution. The "LIST" option from compiler
invocation parameter took precedence.
We also got below warning message at the end of compilation:
IGYDS0139-W Diagnostic messages were issued during processing of
compiler options. These messages are located at the
beginning of the listing.
Thanks. |
|
Back to top |
|
|
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 765 Location: Whitby, ON, Canada
|
|
|
|
Were there any pre-compile errors? When I reproduced your code (with a minor change to point to one of our local tables), I got the following error:
Code: |
DSNH5011I E DSNHSMUD LINE 81 COL 24 HOST VARIABLE ARRAY "WS-BRANCH-NUM" IS EITHER NOT DEFINED OR IS NOT USABLE
FETCH NEXT ROWSET FROM TST_CSR FOR 10 ROWS INTO : WS-BRANCH-NUM |
|
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
May be a wild guess to declare it like below if 10 is going to be constant all the times.
Code: |
01 WS-CURSOR_DATA-HD.
05 WS-SEC-NO PIC X(5) OCCURS 10 TIMES. |
|
|
Back to top |
|
|
kameswaramanoj.Akella
New User
Joined: 28 Mar 2013 Posts: 7 Location: india
|
|
|
|
Try fetching the data into the group variable 'WS-CURSOR_DATA-HD' |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
Aaargh. just noticed the underscore.
AFAIK : no underscores in host-variables. |
|
Back to top |
|
|
kameswaramanoj.Akella
New User
Joined: 28 Mar 2013 Posts: 7 Location: india
|
|
|
|
Hi GuyC,
copied it from the actual code from the post...I too just noticed |
|
Back to top |
|
|
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 765 Location: Whitby, ON, Canada
|
|
|
|
I re-created the problem, and the underscore does not cause the precompiler to complain, yet the generated Cobol is incorrect.
This looks like a precompiler bug to me. An underscore is a valid character in a Cobol variable name, so the precompiler should have generated valid Cobol code.
This is the DSNHADDR2 call generated when the underscore is present:
Code: |
CALL 'DSNHADD2' USING SQL-AVAR-ADDRS1 IN
SQL-AVAR-LIST4(1) SQL-NULL. |
Change the underscore to a hyphen and the generated code looks like this:
Code: |
CALL 'DSNHADD2' USING SQL-AVAR-ADDRS1 IN
SQL-AVAR-LIST4 WS-LOGON-ID OF FILLER-02(1) SQL-NULL. |
Note: in my version of the code WS-LOGON-ID is the field that occurs 3000 times. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Good spot Don! |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
And thanks for posting!
d |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
underscore is valid in cobol, not in DB2 hostvariable.
This is a very special case : the hostvariable itself does not contain underscore, but the groupfield does;
Could be worth reporting this to IBM.
Thx for investigating, Don. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
Just to add further, if we try to use underscore at sub level like,
Code: |
01 WS-CURSOR-DATA-HD.
05 WS_SEC_NO PIC X(5) OCCURS 3000 TIMES. |
then precompiler doesn't give any error and it goes as a successful compilation. |
|
Back to top |
|
|
|