×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




What happens when you run the query interactively? Have you checked the value of SQLSTT or looked in the job log?

BTW, using SELECT * is bad from a design standpoint. Not that F0311 is likely to change but if it were to change, your program isn't going to work.

Matt

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Donna Fabianke
Sent: Friday, October 03, 2008 9:53 AM
To: rpg400-l@xxxxxxxxxxxx
Subject: SQL fetch problem - skipping records

I am creating a cursor on a file and then doing a fetch next to load a
subfile.
The problem I am having is that the fetch seems to be skipping records.
I ran this in debug and for example I have more than 1 record for a
particular invoice. So, if invoice 1 with a date of 1/09/08 for both
records, the fetch gets the first record but then it goes onto the next
date (which is in the order by clause) - the date is rpdivj and the
invoice number is rpdoc.
I appreciate any advice!

C Eval W_Sql='Select * From F0311 where ' +
C W_Field + '=' + W_Value +
C ' Order by RPDIVJ, RPDOC'
C/Exec SQL
C+ Prepare @S1 from :W_Sql
C/End-Exec
C/Exec SQL
C+ Declare CsrF0311 Cursor For @S1
C/End-Exec
C/Exec SQL Open CsrF0311 USING :W_Field, :W_Value
C/End-Exec


Fetch statements:
C/Exec SQl
C+ Fetch From CsrF0311
C+ Into :DS0311
C/End-Exec

Thanks,

Donna Fabianke
McLane Company
Sr. Programmer/Analyst
254-771-7094
Donna.Fabianke@xxxxxxxxxxxx <mailto:Donna.Fabianke@xxxxxxxxxxxx>


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

Replies:

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

This mailing list archive is Copyright 1997-2026 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.