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



Did you look at SQLCOD or SQLSTT after the prepare? Since you ran it in debug, 
your job log should have information about the first failure.

Matt

-----Original Message-----
From: THarteau@xxxxxxxxxxxxxxxxxx [mailto:THarteau@xxxxxxxxxxxxxxxxxx]
Sent: Wednesday, April 21, 2004 3:59 PM
To: RPG programming on the AS400 / iSeries
Subject: Re: SQL Variable Declare Statement



Hi,
      My statement looks OK, but I am getting SQL Code 501, Cursor not
open. I went through the list of things that could be wrong, but none seem
to apply. Can anyone see what I am doing wrong?

0154.00 C                   EVAL      SelSmt =
0155.00 C                             'SELECT * FROM JTD WHERE JDJBT#
= :JOBNO '
0156.00 C                   EVAL      SqlSmt =
0157.00 C                             SelSmt + 'ORDER BY ' + L1Fld + ',' +
L2Fld
0158.00 C                              + ',' + L3Fld + ',' + 'JDPROD'

In debug, this give me SELECT * FROM JTD WHERE JDJBT# = :JOBNO ORDER BY
JDPSYS,JDBPRT,JDSSYM,JDPROD

0160.00 C******************************
0161.00 C/EXEC SQL
0162.00 C+ PREPARE STMT FROM :SQLSMT
0163.00 C/END-EXEC
0164.00 C******************************
0165.00 C/EXEC SQL
0166.00 C+ DECLARE A CURSOR FOR STMT
0167.00 C/END-EXEC
0168.00 C******************************
0169.00 C/EXEC SQL
0170.00 C+    OPEN A
0171.00 C/END-EXEC
0172.00 C******************************
0173.00 C*
0174.00 C                   EVAL      MorJTD = 'YES'
0175.00 C*
0176.00 C                   DOU       MorJTD = 'NO '
0177.00 C*
0178.00 C/EXEC SQL
0179.00 C+ FETCH NEXT FROM A INTO :JTDRec
0180.00 C/END-EXEC
0183.00 C                   IF        SQLCOD <> 0
0184.00 C                   EVAL      MorJTD = 'NO '
0185.00 C                   ELSE

I also tried the fetch without the next from and got the same error. After
I set on LR, I am closing A.

<===================================================>

Terri Harteau
Felker Brothers Corporation
****************
Paperwork is like kudzu. Both need to be pruned regularly. Usually, a
flamethrower is overkill.      Usually.
****************






_______________________________________________
This is the RPG programming on the AS400 / iSeries (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 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.