Alaska Software Inc. - Problem with EOF function (PostgreSQL)
Username: Password:
AuthorTopic: Problem with EOF function (PostgreSQL)
Leszek NowakProblem with EOF function (PostgreSQL)
on Tue, 05 May 2015 14:17:05 +0200
I am trying the ISAM-Emulation with PGDBE engine.
The code below shows strange problem with eof function.

 
LOCAL cNewTable:='Table01', cLastIndexKey:='', i:=0, nCount:=25000
//create simple table and add <nCount> records:
DbCreate(cNewTable,{{'id','N',9,0},{'lname','C',40,0}}) 
if Table(cNewTable)		
	DbUseArea(.t.,oSession,cNewTable,'TEMP',.t.)
	index on lname tag 'tag1' to (cNewTable)
	set index to (cNewTable)	
	for i:=1 to nCount
		append blank
		replace id with i,lname with 'Name '+str(i,5)		
	next		
	DbCloseArea()
	//reopen and skip through all records in the table:
	DbUseArea(.t.,oSession,cNewTable,'TEMP',.t.)
	set index to (cNewTable)
	DbGoTop()	
	do while !Eof()
		cLastIndexKey:=lname
		i++
		DbSkip()		
	enddo
	MsgBox('Last index key='+Trim(cLastIndexKey);
	+Chr(10)+'recno='+str(Recno());
	+Chr(10)+'loop counter='+Str(i))
	DbCloseArea()
endif

It works properly (but slow) when table has 17000 records or less.
Otherwise, eof function returns TRUE unexpectedly when loop counter is 
between 17000 and 19000 and procedure exits the loop.
The message box shows for example: 
last index key=Name 17828
recno=25001
loop counter=17828
I have tried this sample with different table's size.
I use PostgreSQL 8.3.18 installed as a service on the local Win7 machine.
Does anybody know, what is wrong?

Regards,
Karol Chmielewski
Leszek Nowaknotifications
on Tue, 05 May 2015 14:18:38 +0200
Krzysztof StryjekRe: Problem with EOF function (PostgreSQL)
on Wed, 06 May 2015 11:48:40 +0200
On 2015-05-05 14:17, Leszek Nowak wrote:
> I am trying the ISAM-Emulation with PGDBE engine.
> The code below shows strange problem with eof function.
>
>
> LOCAL cNewTable:='Table01', cLastIndexKey:='', i:=0, nCount:=25000
> //create simple table and add <nCount> records:
> DbCreate(cNewTable,{{'id','N',9,0},{'lname','C',40,0}})
> if Table(cNewTable)		
> 	DbUseArea(.t.,oSession,cNewTable,'TEMP',.t.)
> 	index on lname tag 'tag1' to (cNewTable)
> 	set index to (cNewTable)	
> 	for i:=1 to nCount
> 		append blank
> 		replace id with i,lname with 'Name '+str(i,5)		
> 	next		
> 	DbCloseArea()
> 	//reopen and skip through all records in the table:
> 	DbUseArea(.t.,oSession,cNewTable,'TEMP',.t.)
> 	set index to (cNewTable)
> 	DbGoTop()	
> 	do while !Eof()
> 		cLastIndexKey:=lname
> 		i++
> 		DbSkip()		
> 	enddo
> 	MsgBox('Last index key='+Trim(cLastIndexKey);
> 	+Chr(10)+'recno='+str(Recno());
> 	+Chr(10)+'loop counter='+Str(i))
> 	DbCloseArea()
> endif
>
> It works properly (but slow) when table has 17000 records or less.
> Otherwise, eof function returns TRUE unexpectedly when loop counter is
> between 17000 and 19000 and procedure exits the loop.
> The message box shows for example:
> last index key=Name 17828
> recno=25001
> loop counter=17828
> I have tried this sample with different table's size.
> I use PostgreSQL 8.3.18 installed as a service on the local Win7 machine.
> Does anybody know, what is wrong?
>
> Regards,
> Karol Chmielewski
>
Witam
Your problem seems to be already described in PDR (sorry, due to 
Alaska's server maintenance I can't check its number )
Regards
Marcin Stryjek
Leszek NowakRe: Problem with EOF function (PostgreSQL)
on Thu, 07 May 2015 13:51:29 +0200
Krzysztof Stryjek wrote in message news:26887fba$35640e48$157d0@news.alaska-
software.com...

>Witam
>Your problem seems to be already described in PDR (sorry, due to 
>Alaska's server maintenance I can't check its number )
>Regards
>Marcin Stryjek

Thank you Marcin

There is PDR ID 6625 (SET DELETED ON with pgdbe leads to increased memory 
usage). 
After changing to "SET DELETED OFF" the loop goes to the end of file.

Regards
Karol Chmielewski