switching between indices
Moderator: Rathinagiri
switching between indices
Hi friends,
I know it is possible to have multiple indices of dbf in one index file and then switching between them. In an old clipper book (5.01) I found the following sample: INDEX ON datei INDEX ind1, ind2, ind3.
datei is the german word for file. I suppose ind1, ind2, ind3 are the dbf-fields to be indexed.
But I get a compiler error: syntax error at 'ON'
Can anybody help please?
Robert
I know it is possible to have multiple indices of dbf in one index file and then switching between them. In an old clipper book (5.01) I found the following sample: INDEX ON datei INDEX ind1, ind2, ind3.
datei is the german word for file. I suppose ind1, ind2, ind3 are the dbf-fields to be indexed.
But I get a compiler error: syntax error at 'ON'
Can anybody help please?
Robert
Re: switching between indices
Index syntax is:
Code: Select all
INDEX ON <expKey> [TAG <cOrderName>] [TO <cOrderBagName>]
[FOR <lCondition>] [ALL]
[WHILE <lCondition>] [NEXT <nNumber>]
[RECORD <nRecord>] [REST]
[EVAL <bBlock>] [EVERY <nInterval>]
[UNIQUE] [ASCENDING|DESCENDING]
[USECURRENT] [ADDITIVE]
[CUSTOM] [NOOPTIMIZE]
Re: switching between indices
Thank you Marek,
I found this sample I did some years ago:
Procedure OpenTables
USE bbpers alias bbpers codepage ("DE850") new
index on name+vname to name
index on persnr to persnr
set index to name,persnr
Return
switching is done by
dbsetorder(1)
dbsetorder(2)
I found this sample I did some years ago:
Procedure OpenTables
USE bbpers alias bbpers codepage ("DE850") new
index on name+vname to name
index on persnr to persnr
set index to name,persnr
Return
switching is done by
dbsetorder(1)
dbsetorder(2)
- AUGE_OHR
- Posts: 2064
- Joined: Sun Aug 25, 2019 3:12 pm
- DBs Used: DBF, PostgreSQL, MySQL, SQLite
- Location: Hamburg, Germany
Re: switching between indices
hi,
Index can use Different Fields but than it must be a String:to switch Index use
! Note : allways open ALL Index belong to DBF else you get Index Corruption
Tip : Use a Function NET_USE( cDBF ) to open DBF and Index
where do you get Syntax "codepage ("DE850")" fromROBROS wrote: ↑Sun Sep 08, 2019 5:44 pmCode: Select all
USE bbpers alias bbpers codepage ("DE850") new
Index can use Different Fields but than it must be a String:
Code: Select all
INDEX ON STREET + STR(NUMBER) TO Index_Street
// or
INDEX ON STREET + STR(NUMBER) TAG "MyStreet" TO Index_Street
Code: Select all
SET ORDER TO [<nIndex>]
// or
SET ORDER TO TAG <cTagName>
//or
DbSetOrder( <nIndex> ) --> NIL
//or
OrdSetfocus( [<cTagName>|<nIndex>] )
Tip : Use a Function NET_USE( cDBF ) to open DBF and Index
Code: Select all
FUNCTION NET_USE( cDBF , lExlusive)
LOCAL lRet := .F.
LOCAL nMaxTry := 10
LOCAL nTry := 0
DO WHILE nTry < nMaxTry
DO CASE
CASE EMPTY( cDBF )
RETURN .F.
CASE cDBF = "KUNDE"
USE KUNDE NEW
CASE cDBF = "ARTIKEL"
USE ARTIKEL NEW
ENDCASE
// check for Error
IF NetErr()
nTry++
LOOP
ELSE
// set Index
DO CASE
CASE cDBF = "KUNDE"
SET INDEX TO K1, K2, K3
CASE cDBF = "ARTIKEL"
SET INDEX TO A1,A2
...
ENDCASE
lRet := .T.
EXIT
ENDIF
ENDDO
RETURN lRet
have fun
Jimmy
Jimmy
Re: switching between indices
That is how the codepage can be set:
request HB_CODEPAGE_DE850
REQUEST HB_SETCODEPAGE
set( _SET_CODEPAGE, "DE850" )
Thank you for your Index-tip. The way I did works fine.
Robert
request HB_CODEPAGE_DE850
REQUEST HB_SETCODEPAGE
set( _SET_CODEPAGE, "DE850" )
Thank you for your Index-tip. The way I did works fine.
Robert
Re: switching between indices
This is in Harbour std.ch:AUGE_OHR wrote: ↑Sun Sep 08, 2019 8:09 pmwhere do you get Syntax "codepage ("DE850")" fromROBROS wrote: ↑Sun Sep 08, 2019 5:44 pmCode: Select all
USE bbpers alias bbpers codepage ("DE850") new
Code: Select all
#command USE <(db)> [VIA <rdd>] [ALIAS <a>] [<nw: NEW>] ;
[<ex: EXCLUSIVE>] [<sh: SHARED>] [<ro: READONLY>] ;
[CODEPAGE <cp>] [INDEX <(index1)> [, <(indexN)>]] => ;
dbUseArea( <.nw.>, <rdd>, <(db)>, <(a)>, ;
iif( <.sh.> .OR. <.ex.>, ! <.ex.>, NIL ), <.ro.> [, <cp>] ) ;
[; dbSetIndex( <(index1)> )] ;
[; dbSetIndex( <(indexN)> )]
- AUGE_OHR
- Posts: 2064
- Joined: Sun Aug 25, 2019 3:12 pm
- DBs Used: DBF, PostgreSQL, MySQL, SQLite
- Location: Hamburg, Germany
Re: switching between indices
AHA ... niceKDJ wrote: ↑Sun Sep 08, 2019 8:30 pm This is in Harbour std.ch:Code: Select all
#command USE <(db)> [VIA <rdd>] [ALIAS <a>] [<nw: NEW>] ; [<ex: EXCLUSIVE>] [<sh: SHARED>] [<ro: READONLY>] ; [CODEPAGE <cp>] [INDEX <(index1)> [, <(indexN)>]] => ; dbUseArea( <.nw.>, <rdd>, <(db)>, <(a)>, ; iif( <.sh.> .OR. <.ex.>, ! <.ex.>, NIL ), <.ro.> [, <cp>] ) ; [; dbSetIndex( <(index1)> )] ; [; dbSetIndex( <(indexN)> )]
thx for Answer
have fun
Jimmy
Jimmy