Serious problem with .NTX created with "index on"

Serious problem with .NTX created with "index on"

Postby max » Thu Sep 11, 2008 9:44 am

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

Code: Select all  Expand view
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 view
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 view
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
User avatar
max
 
Posts: 128
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy

Postby Marc Vanzegbroeck » Thu Sep 11, 2008 10:19 am

You have to use
Code: Select all  Expand view
INDEX ON lastname INDEX myntx

instead of mydbf->lastname
if you want to open the file with
Code: Select all  Expand view
USE mydbf INDEX myntx ALIAS myalias

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

Marc
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Postby max » Thu Sep 11, 2008 10:30 am

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
max
 
Posts: 128
Joined: Fri Jun 30, 2006 2:14 pm
Location: Ancona - Italy

Postby nageswaragunupudi » Thu Sep 11, 2008 12:03 pm

>
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
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Euclides » Thu Sep 11, 2008 12:23 pm

Max,
The good old Clipper, behaves the same manner... :-))
Regards,
Euclides
User avatar
Euclides
 
Posts: 156
Joined: Wed Mar 28, 2007 1:19 pm

Postby James Bott » Thu Sep 11, 2008 3:09 pm

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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 81 guests