× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Birgitta

That was it. The prepare, declare, open and fetch were all in subroutines,
but the close cursor was in the mainline code. After moving the close to a
subroutine at the end of the program it get's through the pre-compiler
successfully.

I left the prepare in front of the declare and that didn't generate an
error, presumably because it doesn't reference the cursor.

I can see why the close was reported as an error, but would have thought
that the open and fetch would have recognised that the cursor had been
defined at that point.

Thanks

Jonathan



-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Birgitta Hauser
Sent: 15 June 2010 13:22
To: 'RPG programming on the IBM i / System i'
Subject: AW: SQL cursor declaration in RPG 400 program

The DECLARE Cursors statement must "physically" precede all other
SQL-Statement that use this cursor within the source. (Independent in which
sequence the SQL statements are executed).

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"

-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im
Auftrag von Jonathan Mason
Gesendet: Tuesday, 15. June 2010 13:52
An: rpg400-l@xxxxxxxxxxxx
Betreff: SQL cursor declaration in RPG 400 program

Hi Everyone

I'm having to modify an old, old, old RPG 400 program and need to embed
some SQL into it, however after making my changes the SQL pre-compiler
throws out an error saying that the cursor needs to be defined first.

The section of code that prepares, declares and opens the cursor looks
like this:

<snip>
6992 C/Exec SQL
6992 C+ Prepare prpSQL from :wSQL
6992 C/End-Exec
6992 C*
6992 C* 4. If there were no errors then declare the cursor...
6992 C*
6992 C SQLCOD IFEQ *ZEROS
6992 C*
6992 C/Exec SQL
6992 C+ Declare csrSQL cursor for prpSQL
6992 C/End-Exec
6992 C*
6992 C* 5. If there were no errors then open the cursor...
6992 C*
6992 C SQLCOD IFEQ *ZEROS
6992 C*
6992 C/Exec SQL
6992 C+ Open csrSQL
6992 C/End-Exec
6992 C ENDIF
</snip>

However, the pre-compiler report shows the following errors:

Record *...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+...
258 6992 C+ Close csrSQL
780 6992 C+ Open csrSQL
796 6992 C+ Fetch csrSQL into :wRRNA, :wRRNB, :wTYPE
5722ST1 V5R4M0 060210 Create SQL RPG Program
DIAGNOSTIC MESSAGES
MSG ID SEV RECORD TEXT
SQL0504 35 258 Position 16 Cursor CSRSQL not declared.
SQL0504 35 780 Position 15 Cursor CSRSQL not declared.
SQL0504 35 796 Position 16 Cursor CSRSQL not declared.

I have a similar piece of code in an ILE module and that compiles fine.
I can't see anything obviously wrong with the code and was wondering if
anybody had any ideas?

Thanks

Jonathan







_______________________________________________________
This message was sent using NOCC v1.14 webmail software
_______________________________________________________





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.