Serious problem with .NTX created with "index on"

Post Reply
User avatar
max
Posts: 128
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy

Serious problem with .NTX created with "index on"

Post by max »

I have problems with the "index on" command.
I create my index from inside my procedure with:

Code: Select all | Expand

USE mydbf 
INDEX ON mydbf->lastname INDEX myntx

If i open the .dbf and .ntx with:
USE mydbf INDEX myntx

all works ok (apparently, but i have problems moving record from my browses, etc.), but if i open the same files with the alias clause:

Code: Select all | Expand

USE mydbf INDEX myntx ALIAS myalias

i receive a runtime error "Error base 1002/ ALIAS mydbf DOES NOT EXIST" (!?) .
I receive the same error (on the 2nd row) if i try to open the .ntx file with:

Code: Select all | Expand

USE mydbf ALIAS myalias
SET INDEX TO myntx

If i create the same .ntx file with DBU utility of clipper 5.2, all works ok!

Please help me! There is a bug with the "INDEX ON" command?
Or something wrong or incomplete in my code?
Thank you.
max

FWH 8.04 - XHARBOUR 1.1.0
Marc Vanzegbroeck
Posts: 1163
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Post by Marc Vanzegbroeck »

You have to use

Code: Select all | Expand

INDEX ON lastname INDEX myntx

instead of mydbf->lastname
if you want to open the file with

Code: Select all | Expand

USE mydbf INDEX myntx ALIAS myalias

because the alias 'mydbf' does't exist if you open it with ALIAS myalias

Marc
User avatar
max
Posts: 128
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy

Post by max »

Thank you Marc, but i use the switch /w compiling my .prg, so i can't delete the alias ref. because the harbour compiler stop with "ambigous reference" error in "lastname" variable.
However, if i delete the switch /w and recompiling my .prg, all is right, so your suggest is ok.

A few seconds ago i find the solution for manteining the switch /w and solving the problem.
Reading some .prg in \FWH\SAMPLES directory, i found that i can use the alias "field", like this:

INDEX ON field->lastname to myntx

In this mode, all is ok and (finally!) my xbrowses work fine!
Thank you.
Bye.
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Post by nageswaragunupudi »

>
INDEX ON field->lastname to myntx
>

It is always better not to use alias in index expressions. INDEX ON LASTNAME TO MYNTX is the best and recommended way.

It is desirable that the database understands the expression independant of our program. Even field-> is not necessary and desirable to have just the name of the fields
Regards

G. N. Rao.
Hyderabad, India
User avatar
Euclides
Posts: 156
Joined: Wed Mar 28, 2007 1:19 pm

Post by Euclides »

Max,
The good old Clipper, behaves the same manner... :-))
Regards,
Euclides
User avatar
James Bott
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Max,

>A few seconds ago i find the solution for manteining the switch /w and solving the problem.
>Reading some .prg in \FWH\SAMPLES directory, i found that i can use the alias "field", like this:

You can (and should) also declare all your fieldnames using the FIELD statement like this:

field lastname
...
index on lastname to myntx

Regards,
James
Post Reply