Board index » delphi » DbiAddIndex & DbiRegenIndex

DbiAddIndex & DbiRegenIndex

Hi friends. I want to regenerate a non-maintainded NDX index for a DBF
table.

I make use of DbiRegenIndex because the index already exists at the time
I need to regenerate it.

My application calls DbiRegenIndex, the index is regenerated, and
DBIERR_NONE is returned. So far so good.

But any successive call to DbiRegenIndex returns DBIERR_NOSUCHINDEX, and
the index is not regenerated.

The returned DBIERR_NOSUCHINDEX is a lie, because the index has just
been regenerated from the previous DbiRegenIndex call.

How can you explain this ? Many thanks from Alvise.

 

Re:DbiAddIndex & DbiRegenIndex


Alvise,

Out of curiosity, how do you produce non maintained indexes on a dbf
table. I have tried using Database desktop (with "Maintained"
unchecked) and in code using DbiAddIndex with the IdxDesc field
bMaintained set to False. In both cases I produce an NDX index but this
is updated when I add records to the table (Using a conventional TTable
arrangement). Surely this should not happen.

Bob
---  
Sent using Virtual Access 5.01 - download your freeware copy now
http://www.atlantic-coast.com/downloads/vasetup.exe

Re:DbiAddIndex & DbiRegenIndex


Quote
Bob Villiers wrote:
> Out of curiosity, how do you produce non maintained indexes on a dbf
> table. I have tried using Database desktop (with "Maintained"
> unchecked) and in code using DbiAddIndex with the IdxDesc field
> bMaintained set to False.

Almost all that I learned about BDE is explained at:

http://www.hochfeiler.it/alvise/BDE.HTM

Not explained there is the possibility to create DBFs and NDXs
dynamically (without using Database Desktop). I can send you the code,
if you want.

Quote
>In both cases I produce an NDX index but this
> is updated when I add records to the table (Using a conventional TTable
> arrangement). Surely this should not happen.

NDX files *are* update when they are opened at the time the table is
being updated. Anycase I don't use TTable.

Hope I answered properly to your question. Regards from Alvise.

Re:DbiAddIndex & DbiRegenIndex


Alvise,

Quote
> NDX files *are* update when they are opened at the time the table is
> being updated.

Right, misunderstanding on my part. I have now got NDX indexes to work
as expected so I can now look at your original question. I will get
back to you.

Bob
---

Sent using Virtual Access 5.01 - download your freeware copy now
http://www.atlantic-coast.com/downloads/vasetup.exe

Re:DbiAddIndex & DbiRegenIndex


Alvise,

I have tested using DbiRegenIndex from Delphi multiple times with no
problem. The code I used is:

i:= DbiRegenIndex(Table1.DBHandle,nil,'NDXTST.DBF',szDBase
,'LAST.NDX','',1);
Showmessage(IntToHex(i,4));

On each occasion I got DBIERR_NONE except when I tried it with the
index open when I got DBIERR_INDEXOPEN.

Bob
---
Sent using Virtual Access 5.01 - download your freeware copy now
http://www.atlantic-coast.com/downloads/vasetup.exe

Re:DbiAddIndex & DbiRegenIndex


Quote
Bob Villiers wrote:
> I have tested using DbiRegenIndex from Delphi multiple times with no
> problem. The code I used is:

> i:= DbiRegenIndex(Table1.DBHandle,nil,'NDXTST.DBF',szDBase
> ,'LAST.NDX','',1);
> Showmessage(IntToHex(i,4));

> On each occasion I got DBIERR_NONE except when I tried it with the
> index open when I got DBIERR_INDEXOPEN.

Thanks Bob. I am using BCB3 instead of Delphi, and my problem still
remains. I must check again the code from the beginning. Very strange.
Fortunately the code is short.

Thanks again and regards from Alvise.

Other Threads