Fetch just two records then stop

tomw

Active Member
I am writing a HR change report based on the F08042 table. I need a routine that will allow me to fetch a record then fetch the next record and then stop. I am currently using

Fetch.F08042
Address
Data Item
History Data -> Variable Field

Fetch Next.F08042
History Data -> Variable Field2


Fetch Next but it loops until it fails. I don't know how to stop the event.

Xe B7333 SP22 Fat Client MSSQL Windows2000
confused.gif
confused.gif
 
Try:
Select:F08042 (selection criteria)
FetchNext:F08042
-> store your first record of data
FetchNext:F08042
-> store your second record of data

Remember to put in your logic for 'just in case' you don't fetch anything.

(db)
 
Hi,

Using a counter,you can control.For example,

Va_Count = 0
Select.F08042
FetchNext.F08042
While SV_FILEIO_STATUS = CO_SUCCESS and VA_Count<1
Va_Count=Va_Count+1
FetchNext.F08042
End While

Thsi means that,your record is fetched twice and will come out of the loop when it sees the counter greater than equal 1(in this case you already have 2 fetches).With this you can control the number of records you want to fetch by changing the counter.

Hope this helps!!
 
Does it make a difference if you use Fetch single or Select to get the first record.
 
The assumption is, Yes - it makes a difference if you use Fetch Single with Fetch Next... but, honestly - I haven't tried.

The Select Statement 'selects' all the records with matching criteria, fetch next selects from 'the cursor'. Fetch Single creates it's own selection - I don't know that a fetch.next after a fetch.single would retrieve the right data.

(db)
 
Back
Top