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.