Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

RPG assistance

416 views
Skip to first unread message

Jo

unread,
May 23, 2006, 3:39:29 AM5/23/06
to
Hi.
I'm trying to run a rpg program to do a select from a db2 table. The
code is pasted below. I keep getting the following errors during
compile using CRTSQLRPGI statement:

SQL0312 30 23 Position 26 Variable ID not defined or not usable.

SQL0312 30 23 Position 31 Variable NAME not defined or not
usable.

I have also tried CRTSQLRPG statement. Same issue. Compile is not
successful.

my table is created as follows:

create table customer(custid int, custnm char(20))

Any advice would be appreciated.

F* FILE DECLARATION FOR QPRINT
F*
FQPRINT O F 132 PRINTER
C*
C Z-ADD0 ID 50
C MOVE *BLANK NAME 9
C*
C/EXEC SQL WHENEVER SQLERROR GOTO UPDERR
C/END-EXEC
C*
C/EXEC SQL DECLARE C1 CURSOR FOR
C+ SELECT CUSTID, CUSTNM FROM CUSTOMER
C+ WHERE CUSTID = 1
C/END-EXEC
C*
C/EXEC SQL
C+ OPEN C1
C/END-EXEC
C/EXEC SQL WHENEVER NOT FOUND GO TO DONE
C/END-EXEC
C SQLCOD DOUNE0
C/EXEC SQL
C+ FETCH C1 INTO :ID, :NAME
C/END-EXEC
C SQLCODE IFEQ 0
C EXCPTOUT
C ENDIF
C ENDDO
C DONE TAG
C/EXEC SQL
C+ CLOSE C1
C/END-EXEC
C ERROR TAG
C SETON LR
C RETRN
C*
OQPRINT E OUT
O CUSTID4 5
O CUSTNM 17

Jo

unread,
May 23, 2006, 5:26:23 AM5/23/06
to
With the following code the precompile goes through:

F* FILE DECLARATION FOR QPRINT
F*
FQPRINT O F 132 PRINTER

D*
DID S 10I 0
DNAME S 20A
D*


C/EXEC SQL WHENEVER SQLERROR GOTO UPDERR
C/END-EXEC
C*
C/EXEC SQL DECLARE C1 CURSOR FOR
C+ SELECT CUSTID, CUSTNM FROM CUSTOMER
C+ WHERE CUSTID = 1
C/END-EXEC
C*
C/EXEC SQL
C+ OPEN C1
C/END-EXEC
C/EXEC SQL WHENEVER NOT FOUND GO TO DONE
C/END-EXEC
C SQLCOD DOUNE 0
C/EXEC SQL
C+ FETCH C1 INTO :ID, :NAME
C/END-EXEC
C SQLCODE IFEQ 0

C EXCEPT OUT


C ENDIF
C ENDDO
C DONE TAG
C/EXEC SQL
C+ CLOSE C1
C/END-EXEC
C ERROR TAG
C SETON LR
C RETRN

OQPRINT E OUT
O ID
O NAME


However I get a lot of sev 40 errors in the spool file:

*RNF2318 00 1 No overflow indicator is specified; indicator
assigned and
automatic skip to 06 generated.

*RNF6011 00 1 The Space and Skip entries are blank and no PRTCTL
keyword
specified; Space-After defaults to 1.

*RNF7031 00 34 The name or indicator is not referenced.

*RNF0262 20 5 Entry not left-adjusted; defaults to left-adjusted.

*RNF5032 20 1 Result-Field entry is not blank for the specified
operation
defaults to blanks.

*RNF5014 30 1 Operation code is not valid; specification is
ignored.
*RNF5053 30 1 Resulting-Indicators entry is blank for specified
operation
specification is ignored.

*RNF7030 30 2 The name or indicator is not defined.

*RNF7043 30 3 Target of GOTO or CABxx operation is not a label;
the
specification is ignored.

*RNF7023 40 1 The Compiler cannot determine how the program can
end.

Is there anythign I have missed out?

Thanks a lot.

Jo

unread,
May 23, 2006, 7:25:06 AM5/23/06
to
Finally I now only have 1 Sev 30 message:

RNF0257 30 2 Form-Type entry for main procedure not valid or out
of
sequence.

Any ideas?

Thanks a lot.

Dika

unread,
May 23, 2006, 10:18:31 AM5/23/06
to

> C SQLCODE IFEQ 0
> C EXCEPT OUT
> C ENDIF
> C ENDDO
> C DONE TAG

This is RPGIV syntax


> C ERROR TAG
> C SETON LR
> C RETRN

This is RPG III syntax


You can't mix these two versions of language.

Barbara Morris

unread,
May 23, 2006, 8:28:00 PM5/23/06
to
Jo wrote:
>
> Finally I now only have 1 Sev 30 message:
>
> RNF0257 30 2 Form-Type entry for main procedure not valid or out
> of
> sequence.
>

I assume you have converted your source to RPG IV? As Dika said, your
original source was (mostly) RPG III, but if you are only getting one
RNF message, it sounds like it is now all RPG IV.

Message RNF0257 is issued when the specs are not in the order H F D I C
O P. The listing should show exactly which lines are getting the
RNF0257 messages.

0 new messages