Page 1 of 2
CDX Index File errors.
Posted: Sat Jun 02, 2012 8:52 am
by dougtanner
I have a problem when a .CDX is created in the following example. The index key is 140 characters with the field “Collection” included. xBase++ does not like this length and errors when the index is opened. It I remove “Collection”. The key index length is 85 and the program does not error. The docs state the “Max length for both INDEX plus FOR expression is 512 characters”. What am I doing wrong?
Thanks for your time.
Doug
PROCEDURE MAIN
LOCAL mDBPath := ""
LOCAL mDBIndex := "TESTCDX"
LOCAL mCdbKeyC := 'RunCode + EndPeriod + StrPeriod + Sequence + ' +;
' EndYrWk + StrYrWk + Type + Plant + PMSType + SysTyGrIt + Collection'
LOCAL mBdbKeyC := {|| RunCode + EndPeriod + StrPeriod + FIELD->Sequence +;
EndYrWk + StrYrWk + Type + Plant + PMSType + SysTyGrIt + FIELD->Collection}
DBCREATE("TESTCDX",{;
{"RunCode","C", 5, 0},;
{"EndPeriod","C", 4, 0},;
{"StrPeriod","C", 4, 0},;
{"EndYrWk","C", 4, 0},;
{"StrYrWk","C", 4, 0},;
{"Sequence","C", 2, 0},;
{"RPTSEQ","C", 8, 0},;
{"Type","C", 1, 0},;
{"Plant","C", 4, 0},;
{"A","C", 17, 0},;
{"PMSType","C", 2, 0},;
{"SysTyGrIt","C",55, 0},;
{"Collection","C",55, 0};
})
USE TESTCDX NEW EXCLUSIVE VIA "DBFCDX"
* Create The Indexes
@24,0 SAY PADC("Creating PMS Customer Data Code Order Indexes",80)
* ALTD()
* the following errors with a "Length of database field exceeded" when
* typed at the debugger command line
ORDCREATE("TESTCDX", "CUSTOMER_O", mcdbkeyC, mbdbkeyC)
SET INDEX TO
* This errors with a "file cannot be opened"
SET INDEX TO ("TESTCDX")
RETURN
Re: CDX Index File errors.
Posted: Sat Jun 02, 2012 10:05 am
by rdonnay
Doug -
I suggest adding FIELD-> to the front of each field name in the index and see if it helps.
Roger
Re: CDX Index File errors.
Posted: Sat Jun 02, 2012 1:01 pm
by Auge_Ohr
dougtanner wrote:I have a problem when a .CDX is created in the following example. The index key is 140 characters with the field “Collection” included. xBase++ does not like this length and errors when the index is opened. It I remove “Collection”. The key index length is 85 and the program does not error. The docs state the “Max length for both INDEX plus FOR expression is 512 characters”. What am I doing wrong?
dont know where you got these wrpng Information, see PDR
5694
For fields of type character the maximum length of the index value
is 120 characters. When the CDXDBE runs is in FOXPRO2X or COMIX mode
then the maximum length of the key value is 240. This is not documented.
Re: CDX Index File errors.
Posted: Mon Jun 04, 2012 9:06 am
by dougtanner
Thanks for you help. Alaska support agrees that the documentation is misleading (Translation "It's Wrong") and recommends limited the length of the key for CDXs to 100 characters. Without much effort, I can rewrite the code. I would prefer not to go with COMIX or FOXPRO2. (Alaska said, and I verified that my example would not run in FOXPRO).
Doug
Re: CDX Index File errors.
Posted: Mon Jun 04, 2012 9:23 am
by rdonnay
Doug -
What is your reason for not liking COMIX?
I used this format in all of my Clipper apps.
Roger
Re: CDX Index File errors.
Posted: Mon Jun 04, 2012 10:26 am
by dougtanner
Hi Roger,
" What is your reason for not liking COMIX?"
Fear of the unknown and I couldn't get it to work. I tried adding:
DbeInfo( COMPONENT_ORDER, CDXDBE_MODE, CDXDBE_FOXPRO2X )
and it still didn't work. How can I enable COMIX?
Doug
Re: CDX Index File errors.
Posted: Mon Jun 04, 2012 10:39 am
by rdonnay
DbeInfo( COMPONENT_ORDER, CDXDBE_MODE, CDXDBE_COMIX )
Re: CDX Index File errors.
Posted: Mon Jun 04, 2012 12:31 pm
by dougtanner
Hi Roger,
I added "COMIX" to my DBESYS. Changed my program to the following. It errors when the key length gets to 121.
What am I doing wrong?
Doug
PROCEDURE MAIN
LOCAL mDBPath := ""
LOCAL mDBIndex := "TESTCDX"
LOCAL cDBKeyC := "KeyField"
LOCAL bDBKeyC := {|| FIELD->KeyField}
FOR mLen := 1 TO 140
IF FILE("TESTCDX.DBF")
FERASE("TESTCDX.DBF")
ENDIF
IF FILE("TESTCDX.CDX")
FERASE("TESTCDX.CDX")
ENDIF
? mlen
DBCREATE("TESTCDX",{;
{"KeyField","C", mLen, 0}})
USE TESTCDX NEW EXCLUSIVE VIA "DBFCDX"
ORDCREATE("TESTCDX", "TESTING", cdbkeyC, bdbkeyC)
SET INDEX TO
* This errors with a "file cannot be opened" when length = 121
SET INDEX TO ("TESTCDX")
CLOSE ALL
NEXT
RETURN
Re: CDX Index File errors.
Posted: Mon Jun 04, 2012 1:02 pm
by Auge_Ohr
dougtanner wrote:I added "COMIX" to my DBESYS. Changed my program to the following. It errors when the key length gets to 121.
What am I doing wrong?
"where" is you DBESYS ? did you compile and link it after modification ?
if you do not use a *.XPJ you have to modify your "Main" this Way
Code: Select all
PROCEDURE dbeSys()
// NTX
IF !DbeLoad( "DBFDBE", .T. )
ALERT( MSG_DBFDBE_NOT_LOADED, { "OK" } )
ENDIF
IF !DbeLoad( "NTXDBE", .T. )
ALERT( MSG_NTXDBE_NOT_LOADED, { "OK" } )
ENDIF
IF !DbeBuild( "DBFNTX", "DBFDBE", "NTXDBE" )
ALERT( MSG_DBFNTX_NOT_CREATED, { "OK" } )
ENDIF
// CDX
IF !DbeLoad( "CDXDBE", .T. )
ALERT( MSG_CDXDBE_NOT_LOADED", { "OK" } )
ENDIF
IF !DbeLoad( "FOXDBE", .T. )
ALERT( MSG_FOXDBE_NOT_LOADED, { "OK" } )
ENDIF
IF !DbeBuild( "FOXCDX", "FOXDBE", "CDXDBE" )
ALERT( MSG_FOXCDX_NOT_CREATED, { "OK" } )
ENDIF
//
// Cl*pper Comix/SixDrive using FOXDBE (DATA-Komponente)
//
DbeInfo( COMPONENT_DATA, FOXDBE_CREATE_2X, .T. )
//
// if used together with Cl*pper
//
DbeInfo( COMPONENT_DATA, FOXDBE_LOCKMODE, FOXDBE_LOCKMODE_CLIPPER )
//
// Cl*pper Comix using CDXDBE (ORDER Komponente)
//
DbeInfo( COMPONENT_ORDER, CDXDBE_MODE, CDXDBE_COMIX )
// default set to CDX
DbeSetDefault( "FOXCDX" )
RETURN
PROCEDURE MAIN
i recommend to create you "Comix" DBF new*** before create Index.
*** if you use more than 1 DBE be sure to use "right" DBE ( here DBENTX and FOXCDX )
Code: Select all
DbCreate( "TESTCDX",{{"KeyField","C", mLen, 0}}, "FOXCDX" )
Re: CDX Index File errors.
Posted: Tue Jun 05, 2012 5:53 am
by dougtanner
Thanks, Auge_Ohr
Those changes to my dbesys() worked. You and Roger are the best!
Doug