index dbf character numbers
Moderator: Rathinagiri
index dbf character numbers
I started invoice 10000. Then later thought it would be wise to change when I changed from clipper to hmg to 100000 to keep then more uniform.
Can anyone think of a way to index these in order. This is a character field so 10002 comes after 100001.
This was a big mistake when searching in an index the numbers are all mixed up.
Thanks, Franco
Can anyone think of a way to index these in order. This is a character field so 10002 comes after 100001.
This was a big mistake when searching in an index the numbers are all mixed up.
Thanks, Franco
All The Best,
Franco
Canada
Franco
Canada
- dragancesu
- Posts: 931
- Joined: Mon Jun 24, 2013 11:53 am
- DBs Used: DBF, MySQL, Oracle
- Location: Subotica, Serbia
Re: index dbf character numbers
Invoice number is numeric, why store in character field. Index number field os ok, it's in clipper and hmg
Re: index dbf character numbers
I use this thru program so was better a character, now is a delema.
I also have a date field in table. I have tried indexiny in inv + date but forgot to change date format to yymmdd I am going to try this.
I also have a date field in table. I have tried indexiny in inv + date but forgot to change date format to yymmdd I am going to try this.
All The Best,
Franco
Canada
Franco
Canada
- SALINETAS24
- Posts: 667
- Joined: Tue Feb 27, 2018 3:06 am
- DBs Used: DBF
- Contact:
Re: index dbf character numbers
Hola Franco, para que el indice por un campo "ALFABETICO" tenga el mismo comportamiento que un indice por campo "NUMERICO", debes rellenar los espacios por CEROS "0"..., quedaria algo asifranco wrote: ↑Tue Jun 08, 2021 4:05 pm I started invoice 10000. Then later thought it would be wise to change when I changed from clipper to hmg to 100000 to keep then more uniform.
Can anyone think of a way to index these in order. This is a character field so 10002 comes after 100001.
This was a big mistake when searching in an index the numbers are all mixed up.
Thanks, Franco
0000001
0000002
0000003
0000010
0000011
0000012
0000101
0000102
0000110
0001000
0001001
0002010
0002030
0010000
0010001
0010002
Saludos y vamos con una cervecita bien fresca
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. 
- AUGE_OHR
- Posts: 2117
- Joined: Sun Aug 25, 2019 3:12 pm
- DBs Used: DBF, PostgreSQL, MySQL, SQLite
- Location: Hamburg, Germany
Re: index dbf character numbers
ho,
i do use STRZERO() when convert Numeric to String to "hold LEN()" of String which a Index need
i do use STRZERO() when convert Numeric to String to "hold LEN()" of String which a Index need
Code: Select all
cSeek := STRZERO(nNum, nLengh_of_Field) + DTOS(dDate)have fun
Jimmy
Jimmy
- serge_girard
- Posts: 3420
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: index dbf character numbers
Franco,
Once this occured to me also. I added new field (eg: NEW_INV_NO) with correct settings; filled it up with correct values; changed programs, indexes etc.
Serge
Once this occured to me also. I added new field (eg: NEW_INV_NO) with correct settings; filled it up with correct values; changed programs, indexes etc.
Serge
There's nothing you can do that can't be done...
Re: index dbf character numbers
SALINETAS24, I can not add 0 before number because can not seek not knowing where number starts.
Serge, I have customers with 25 years of invoices and invoice items. It's hard to change their history.
the date did not work for me because 100898 come right after 10089.
Jimmy I will try to index on value then seek value.
Thanks to you all.
Serge, I have customers with 25 years of invoices and invoice items. It's hard to change their history.
the date did not work for me because 100898 come right after 10089.
Jimmy I will try to index on value then seek value.
Thanks to you all.
All The Best,
Franco
Canada
Franco
Canada
- AUGE_OHR
- Posts: 2117
- Joined: Sun Aug 25, 2019 3:12 pm
- DBs Used: DBF, PostgreSQL, MySQL, SQLite
- Location: Hamburg, Germany
Re: index dbf character numbers
hi,
so you can SEEK() this
create new Index this Way
Code: Select all
USE BLABLA EXCLUSIVE
INDEX ON STRZERO(FIELD->ABC, 10)+DTOS(FIELD->DDATE) TO XYZ
Code: Select all
cSeek := STRZERO(nNum, 10) + DTOS(dDate)
SEEK(cSeek)have fun
Jimmy
Jimmy
Re: index dbf character numbers
AUGE_OHR wrote: ↑Wed Jun 09, 2021 1:00 am hi,create new Index this Way
so you can SEEK() thisCode: Select all
USE BLABLA EXCLUSIVE INDEX ON STRZERO(FIELD->ABC, 10)+DTOS(FIELD->DDATE) TO XYZCode: Select all
cSeek := STRZERO(nNum, 10) + DTOS(dDate) SEEK(cSeek)
IMHO it should be like this:
Code: Select all
INDEX ON Val ( Inv_Number ) TO indexfileCode: Select all
SEEK Val ( cSeek_Inv_Number )Re: index dbf character numbers
I get argument error when trying to use strzero.
I can get seek to work. but I always browse the table before picking. This is when the order is not indexed by length of field.
browse gets
10001
10002
100021
10003
I can get seek to work. but I always browse the table before picking. This is when the order is not indexed by length of field.
browse gets
10001
10002
100021
10003
All The Best,
Franco
Canada
Franco
Canada