By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,779 Members | 1,078 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,779 IT Pros & Developers. It's quick & easy.

Cobol precompiler query

P: n/a
I am getting a precompiler error which I don't understand.

In my Cobol program I have the following code

01 TESTDB.
03 ADDR.
EXEC SQL INCLUDE 'ADDR.cop' END-EXEC.

In the ADDR.cop file I have the following

05 ADDR-LASTNAME PIC X(20).
05 ADDR-FIRSTNAME PIC X(20).
05 ADDR-AGE PIC S9(2) COMP-3.
I then use these in a fetch

EXEC SQL FETCH ADDR_1 INTO
:TESTDB.ADDR.ADDR-LASTNAME
,:TESTDB.ADDR.ADDR-FIRSTNAME
,:TESTDB.ADDR.ADDR-AGE
END-EXEC

When I precompile this I get

60 SQL4007N The host structure "ADDR" has no fields.
59 SQL4007N The host structure "TESTDB" has no fields.
61 SQL0062W Starting INCLUDE of file
"/home/steve/testdb2cobol/dbfields/ADDR.cop".

and then

233 SQL4002N "TESTDB.ADDR.ADDR-AGE" and
"TESTDB.ADDR.ADDR-FIRSTNAME" are undeclared host variables
that cannot both be used as descriptor names in a single
SQL statement.

I don't understand why they are not declared.

Any ideas?


--
Steve

Jun 29 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
>>On 6/29/2007 at 6:35 AM, in message
<5e*************@mid.individual.net>,
Steve Rainbird<ne*********@rainbird.me.nospam.ukwrote:
I am getting a precompiler error which I don't understand.

In my Cobol program I have the following code

01 TESTDB.
03 ADDR.
EXEC SQL INCLUDE 'ADDR.cop' END-EXEC.

In the ADDR.cop file I have the following

05 ADDR-LASTNAME PIC X(20).
05 ADDR-FIRSTNAME PIC X(20).
05 ADDR-AGE PIC S9(2) COMP-3.
I then use these in a fetch

EXEC SQL FETCH ADDR_1 INTO
:TESTDB.ADDR.ADDR-LASTNAME
,:TESTDB.ADDR.ADDR-FIRSTNAME
,:TESTDB.ADDR.ADDR-AGE
END-EXEC

When I precompile this I get

60 SQL4007N The host structure "ADDR" has no fields.
59 SQL4007N The host structure "TESTDB" has no fields.
61 SQL0062W Starting INCLUDE of file
"/home/steve/testdb2cobol/dbfields/ADDR.cop".

and then

233 SQL4002N "TESTDB.ADDR.ADDR-AGE" and
"TESTDB.ADDR.ADDR-FIRSTNAME" are undeclared host
variables
that cannot both be used as descriptor names in a
single
SQL statement.

I don't understand why they are not declared.

Any ideas?
I believe that the precompiler is not recognising the 01 and 03 levels,
because they are not in the copybook. I think you either need to place them
in the copybook or do the following:

EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 TESTDB.
03 ADDR.
EXEC SQL INCLUDE 'ADDR.cop' END-EXEC.
EXEC SQL END DECLARE SECTION END-EXEC.

Frank

Jun 29 '07 #2

P: n/a
"Frank Swarbrick" <Fr*************@efirstbank.comwrote in message
news:46******************@efirstbank.com...
>>>On 6/29/2007 at 6:35 AM, in message
<5e*************@mid.individual.net>,
Steve Rainbird<ne*********@rainbird.me.nospam.ukwrote:
>I am getting a precompiler error which I don't understand.

In my Cobol program I have the following code

01 TESTDB.
03 ADDR.
EXEC SQL INCLUDE 'ADDR.cop' END-EXEC.

In the ADDR.cop file I have the following

05 ADDR-LASTNAME PIC X(20).
05 ADDR-FIRSTNAME PIC X(20).
05 ADDR-AGE PIC S9(2) COMP-3.
I then use these in a fetch

EXEC SQL FETCH ADDR_1 INTO
:TESTDB.ADDR.ADDR-LASTNAME
,:TESTDB.ADDR.ADDR-FIRSTNAME
,:TESTDB.ADDR.ADDR-AGE
END-EXEC

When I precompile this I get

60 SQL4007N The host structure "ADDR" has no fields.
59 SQL4007N The host structure "TESTDB" has no fields.
61 SQL0062W Starting INCLUDE of file
"/home/steve/testdb2cobol/dbfields/ADDR.cop".

and then

233 SQL4002N "TESTDB.ADDR.ADDR-AGE" and
"TESTDB.ADDR.ADDR-FIRSTNAME" are undeclared host
variables
that cannot both be used as descriptor names in a
single
SQL statement.

I don't understand why they are not declared.

Any ideas?

I believe that the precompiler is not recognising the 01 and 03 levels,
because they are not in the copybook. I think you either need to place
them
in the copybook or do the following:

EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 TESTDB.
03 ADDR.
EXEC SQL INCLUDE 'ADDR.cop' END-EXEC.
EXEC SQL END DECLARE SECTION END-EXEC.

Frank

That is exactly what I have got. Although the BEGIN DECLARE is a bit before
these statements.
--
Steve

Jun 29 '07 #3

P: n/a
"Steve Rainbird" <ne*********@rainbird.me.nospam.ukwrote in message
news:5e*************@mid.individual.net...
"Frank Swarbrick" <Fr*************@efirstbank.comwrote in message
news:46******************@efirstbank.com...
>>>>On 6/29/2007 at 6:35 AM, in message
<5e*************@mid.individual.net>,
Steve Rainbird<ne*********@rainbird.me.nospam.ukwrote:
>>I am getting a precompiler error which I don't understand.

In my Cobol program I have the following code

01 TESTDB.
03 ADDR.
EXEC SQL INCLUDE 'ADDR.cop' END-EXEC.

In the ADDR.cop file I have the following

05 ADDR-LASTNAME PIC X(20).
05 ADDR-FIRSTNAME PIC X(20).
05 ADDR-AGE PIC S9(2) COMP-3.
I then use these in a fetch

EXEC SQL FETCH ADDR_1 INTO
:TESTDB.ADDR.ADDR-LASTNAME
,:TESTDB.ADDR.ADDR-FIRSTNAME
,:TESTDB.ADDR.ADDR-AGE
END-EXEC

When I precompile this I get

60 SQL4007N The host structure "ADDR" has no fields.
59 SQL4007N The host structure "TESTDB" has no fields.
61 SQL0062W Starting INCLUDE of file
"/home/steve/testdb2cobol/dbfields/ADDR.cop".

and then

233 SQL4002N "TESTDB.ADDR.ADDR-AGE" and
"TESTDB.ADDR.ADDR-FIRSTNAME" are undeclared host
variables
that cannot both be used as descriptor names in a
single
SQL statement.

I don't understand why they are not declared.

Any ideas?

I believe that the precompiler is not recognising the 01 and 03 levels,
because they are not in the copybook. I think you either need to place
them
in the copybook or do the following:

EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 TESTDB.
03 ADDR.
EXEC SQL INCLUDE 'ADDR.cop' END-EXEC.
EXEC SQL END DECLARE SECTION END-EXEC.

Frank


That is exactly what I have got. Although the BEGIN DECLARE is a bit
before these statements.
--
Steve


Would someone be so kind as to try and compile this test program for me?

IDENTIFICATION DIVISION.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 TESTDB.
03 ADDR.
EXEC SQL INCLUDE 'ADDR.cop' END-EXEC.
EXEC SQL END DECLARE SECTION END-EXEC.
PROCEDURE DIVISION.
A10.
EXEC SQL DECLARE ADDR_1 CURSOR FOR
SELECT ADDR_LASTNAME
FROM ADDR
END-EXEC.
EXEC SQL OPEN ADDR_1 END-EXEC
EXEC SQL FETCH ADDR_1 INTO
:ADDR-LASTNAME
END-EXEC
EXEC SQL CLOSE ADDR_1 END-EXEC
STOP RUN.
~
ADDR.cop should contain the following
05 ADDR-LASTNAME PIC X(20).

Mine does not seem to be recognising the INCLUDE. Does yours compile?

TIA
--
Steve

Jul 2 '07 #4

P: n/a
>>On 7/3/2007 at 2:27 AM, in message
<11**********************@w5g2000hsg.googlegroups. com>, Bernard
Dhooghe<dh******@yahoo.comwrote:
>
Which Cobol Compiler is it?

What command is used to precompile?
The COBOL compiler does not matter. It's the DB2 pre-compile that has the
issue.

Frank

Jul 3 '07 #5

P: n/a
>>On 7/3/2007 at 1:48 AM, in message
<5e*************@mid.individual.net>,
Steve Rainbird<ne*********@rainbird.me.nospam.ukwrote:
Thanks Frank,

I would open a PMR but don't yet have a service agreement. :(

I am currently investigating migrating some Oracle Cobol to run against
DB2
and have just downloaded DB2 for Linux on a trial basis.
Spoil sport.

We are in the midst of purchasing DB2, so if I remember to do it I'll see if
I can open a PMR on this.

In the mean time, for your testing I'd just in-line the entire copybook into
the .sqc program.

Frank

Jul 3 '07 #6

P: n/a
"Frank Swarbrick" <Fr*************@efirstbank.comwrote in message
news:46******************@efirstbank.com...
>>>On 7/3/2007 at 1:48 AM, in message
<5e*************@mid.individual.net>,
Steve Rainbird<ne*********@rainbird.me.nospam.ukwrote:
>Thanks Frank,

I would open a PMR but don't yet have a service agreement. :(

I am currently investigating migrating some Oracle Cobol to run against
DB2
and have just downloaded DB2 for Linux on a trial basis.

Spoil sport.

We are in the midst of purchasing DB2, so if I remember to do it I'll see
if
I can open a PMR on this.

In the mean time, for your testing I'd just in-line the entire copybook
into
the .sqc program.

Frank
thanks,

I have written a pre-pre-compiler to copy in the INCLUDE files. :)

--
Steve

Jul 3 '07 #7

P: n/a
>>On 7/3/2007 at 11:02 AM, in message
<5e*************@mid.individual.net>,
Steve Rainbird<ne*********@rainbird.me.nospam.ukwrote:
"Frank Swarbrick" <Fr*************@efirstbank.comwrote in message
news:46******************@efirstbank.com...
>>>>On 7/3/2007 at 1:48 AM, in message
<5e*************@mid.individual.net>,
Steve Rainbird<ne*********@rainbird.me.nospam.ukwrote:
>>Thanks Frank,

I would open a PMR but don't yet have a service agreement. :(

I am currently investigating migrating some Oracle Cobol to run against
DB2
and have just downloaded DB2 for Linux on a trial basis.

Spoil sport.

We are in the midst of purchasing DB2, so if I remember to do it I'll
see
>if
I can open a PMR on this.

In the mean time, for your testing I'd just in-line the entire copybook
into
the .sqc program.

Frank

thanks,

I have written a pre-pre-compiler to copy in the INCLUDE files. :)
That works! Have fun!

Frank
Jul 5 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.