× 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.



The error message is telling you the problem.

Look at your ILE module again...

You have to have the DECLARE before the PREPARE.

Note: It is the physical order of the statements in the source member
that matters, not the order in which the statement appear to be
executed.

---This Works---

/free
exsr DeclareStmt;
exsr PrepareStmt;

// more stuff
*INLR = *ON;
return;

begsr;
exec SQL
declare csrSQL cursor for prpSQL;
endsr;

begsr;
exec SQL
prepare prpSQL from :mySQLStmt;
endsr;

But this doesn't

---This Works---

/free
exsr DeclareStmt;
exsr PrepareStmt;

// more stuff
*INLR = *ON;
return;

begsr;
exec SQL
prepare prpSQL from :mySQLStmt;
endsr;

begsr;
exec SQL
declare csrSQL cursor for prpSQL;
endsr;


HTH,
Charles


On Tue, Jun 15, 2010 at 7:51 AM, Jonathan Mason
<jonathan.mason@xxxxxxxxxxxxxxxx> wrote:
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
_______________________________________________________




--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



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.