strange execution of Index

strange execution of Index

Postby Silvio.Falconi » Mon Jan 14, 2019 1:00 am

I have a dbf and made 3 index

USE SERVIZI ALIAS SERVIZI
INDEX ON SERVIZI->ID TAG ID TO SERVIZI FOR !deleted()
INDEX ON UPPER(SERVIZI->NAME) TAG NAME TO SERVIZI FOR !deleted()
INDEX ON SERVIZI->ORDINE TAG ORDINE TO SERVIZI FOR !deleted()

Now I wish see the dbf index on Ordine field
If I made
SERVIZI->( DbSetOrder(3 ) ) //ORDINE
SERVIZI->( DBGOTOP() )
XBROWSE()

then I see this

Image

check the last column

if I made

SERVIZI->( DbSetOrder("ordine" ) ) //ORDINE
SERVIZI->( DBGOTOP() )
XBROWSE()

then I see this

Image



why ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: strange execution of Index

Postby James Bott » Mon Jan 14, 2019 8:08 am

What did you expect to see?

We can't see the Ordine column so we can't tell if it is correct.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: strange execution of Index

Postby AntoninoP » Mon Jan 14, 2019 8:25 am

I think the problem for Silvio is that the index "order" is not the number 3.
may be you can use IndexOrd to see what number it is.

or get informations by this piece of code (untested):
Code: Select all  Expand view  RUN
cMsg := ""
for j = 1 to OrdCount()
   if !Empty( IndexKey( j ) )
      OrdSetFocus( j )
      cMsg += Str(j) " OrdName:" + OrdName( j )
      cMsg += " Key: " + IndexKey(j) + CRLF
   endif
next
MsgInfo(cMsg)
SetClipboardData( 1 /* CF_TEXT */, cMsg )
 
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: strange execution of Index

Postby Marc Venken » Mon Jan 14, 2019 10:26 am

Silvio,

Mr. Rao told that there can be a issue when building indexes like this :

INDEX ON SERVIZI->ID TAG ID TO SERVIZI FOR !deleted()

See :

viewtopic.php?f=3&t=33776&hilit=field

Maybe this wil help your problem.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1447
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: strange execution of Index

Postby Silvio.Falconi » Mon Jan 14, 2019 5:06 pm

I have ID as Character sample "0001", name as Character , Ordine as Number
the problem is on ordine field if I use dbsetorder(3) instead of dbsetorder("ordine") is the tag
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: strange execution of Index

Postby James Bott » Mon Jan 14, 2019 6:13 pm

Silvio,

You can't use aliases in an index.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: strange execution of Index

Postby James Bott » Mon Jan 14, 2019 6:26 pm

Silvio,

This code is working fine here.

Code: Select all  Expand view  RUN
#include "fivewin.ch"

Function Main()

   REQUEST DBFCDX
   rddsetdefault( "DBFCDX" )
   SET EXCLUSIVE OFF
   SET(_SET_AUTOPEN, .T. )  


   USE SERVIZI ALIAS SERVIZI
   INDEX ON ID TAG ID TO SERVIZI FOR !deleted()
   INDEX ON UPPER(NAME) TAG NAME TO SERVIZI FOR !deleted()
   INDEX ON ORDINE TAG ORDINE TO SERVIZI FOR !deleted()

   Set order to "name"
   go top
   browse()
   
   set order to "ordine"
   go top
   browse()
   
   set order to 3
   go top
   browse()

Return nil
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: strange execution of Index

Postby FranciscoA » Mon Jan 14, 2019 7:19 pm

Silvio,
DbSetOrder( <nIndexPos> ) --> NIL
Arguments
<nIndexPos>
This is the numeric ordinal position of the index to activate as the controlling index. Indexes are numbered in the sequence they are opened with OrdListAdd(),

try this way:
Code: Select all  Expand view  RUN
SERVIZI->( OrdSetFocus("ORDINE" ) )
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2159
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: strange execution of Index

Postby Silvio.Falconi » Mon Jan 14, 2019 7:40 pm

I made allways servizi->(dbsetorder(number_of_index))
why now I must make servizi->(dbsetorder(tagname))
Incredible!!!!
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: strange execution of Index

Postby James Bott » Mon Jan 14, 2019 7:46 pm

Silvio,

I noticed that the file was already in ORDINE order, so I changed a couple of them. Then when I ran it they were not indexed properly.

Then I realized I had forgotten to delete the existing index before building the indexes. I did that and now it is working.

Code: Select all  Expand view  RUN
Function Main()

   REQUEST DBFCDX
   rddsetdefault( "DBFCDX" )
   SET EXCLUSIVE OFF
   SET(_SET_AUTOPEN, .T. )  

   ferase("servizi.cdx")
   USE SERVIZI ALIAS SERVIZI
   INDEX ON ID TAG ID TO SERVIZI FOR !deleted()
   INDEX ON UPPER(NAME) TAG NAME TO SERVIZI FOR !deleted()
   INDEX ON ORDINE TAG ORDINE TO SERVIZI FOR !deleted()

   Set order to "name"
   go top
   browse()
   
   set order to "ordine"
   go top
   browse()
   
   //set order to 3
   SERVIZI->( DbSetOrder(3 ) )
   go top
   browse()

Return nil

 
Last edited by James Bott on Thu Jan 17, 2019 4:18 pm, edited 1 time in total.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: strange execution of Index

Postby Silvio.Falconi » Mon Jan 14, 2019 8:03 pm

Perhaps
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: strange execution of Index

Postby Silvio.Falconi » Thu Jan 17, 2019 8:02 am

First I never had this error because when I opened the application I went to check if the dbf files were in the specific folder (cDbfpath) and if I did not there I created them and also created the indexes by deleting them first.

Obviously, I first opened the archives in exclusive mode. Now with the opening in the new share mode I can not create the indexes because it requires the exclusive way and consequently I can not make the packs.

So now I have not understood well when I can make indexes and packs to the database.

If a user opens the program from another location on the network, the application can not perform the above check because the files are already opened by another user in another location.

It seems an absurdity and at the same time it seems to me absurd to be able to make a voice alert to all connected users "you have to close because I have to make the indexes to the archives ..!" and then run the indexes and the packs.

1) Can you explain to me when I can make the indexes and the packs
2) when I deliver the application to the client I also have to deliver the indexes?
3)how to check if the archives are open and create indexes?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: strange execution of Index

Postby James Bott » Thu Jan 17, 2019 3:51 pm

Silvio,

1) Can you explain to me when I can make the indexes and the packs

I have been trying to tell you this. You cannot build indexes unless you have the files open in exclusive use.
And you should not be building indexes everytime the program is run--there is no need.

If the program has just been installed, then it should check to see if the databases exist, and if not create them. Then it should open them in exclusive use mode, and build the indexes. Then close the files. Files should then be opened shared whenever they are opened.

From then on, when the program is run and does the check for the databases, it will find them and thus just skip that step.

Do you have a lot of deleted records? If so, why? Most times you can avoid doing packs by reusing deleted records. If you don't reuse them, then an Admin will have to have exclusive use of the files needing to be packed.

2) when I deliver the application to the client I also have to deliver the indexes?

No, see explaination above.

3)how to check if the archives are open and create indexes?


If you can't get exclusive use of the files, then they are open by someone else. And you need to get exclusive use of ALL the files BEFORE you delete the indexes and rebuild them.

Also, you seem to think that the indexes need to be created each time the program is run. Not so. Generally, the only time they need to be created is when they don't exist or when they are corrupted.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
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: Google [Bot] and 42 guests