Pedro Santana Viera
Generic search on composite keys and a generic routine... May 21, 2008 01:04PM |
GuenterP
Re: Generic search on composite keys and a generic routine... May 21, 2008 01:29PM |
Moderator |
Pedro Santana Viera
Re: Generic search on composite keys and a generic routine... May 22, 2008 11:31AM |
Al
Re: Generic search on composite keys and a generic routine... May 22, 2008 01:38PM |
Fabrice Harari
Re: Generic search on composite keys and a generic routine... May 22, 2008 02:08PM |
Marc De Swert
Re: Generic search on composite keys and a generic routine... May 22, 2008 02:14PM |
Marc De Swert
Re: Generic search on composite keys and a generic routine... May 22, 2008 02:20PM |
Pedro Santana Viera
Re: Generic search on composite keys and a generic routine... May 22, 2008 04:04PM |
Pedro Santana Viera
Re: Generic search on composite keys and a generic routine... May 22, 2008 04:15PM |
Pedro Santana Viera
Re: Generic search on composite keys and a generic routine... May 22, 2008 04:21PM |
Peter H.
Re: Generic search on composite keys and a generic routine... May 22, 2008 08:54PM |
Fabrice Harari
Re: Generic search on composite keys and a generic routine... May 23, 2008 05:57AM |
Quote
Pedro Santana Viera
I think I know what you are saying. And this is what I did:
PROCEDURE GetCompositeKeyValue(sTableName is string,sCompositeKeyList is string, sValuesList is string)
i is int = 1
sCompositeKeyItem is string
sItemsList is string = HListItem(sTableName,hLstDetail)
sItem is string
sValueItem is string
sResultado is string = ""
// Recorremos la lista de valores de busqueda para completarlos
sValueItem = ExtractString(sValuesList,firstRank,"/")
WHILE sValueItem <> EOT
sCompositeKeyItem = ExtractString(sCompositeKeyList,i,"+")
sItem = ExtractString(sItemsList,firstRank,CR)
WHILE sItem <> EOT
IF Upper(ExtractString(sItem,1)) = Upper(sCompositeKeyItem) THEN
SWITCH ExtractString(sItem,3)
CASE hItemBoolean:
CASE hItemDate6,...
hItemDate8,...
hItemDateTime,...
hItemTimeLength,...
// hItemInteger1,... ----> I don't know why WD11 says it don't exist
hItemInteger2,...
hItemInteger4,...
hItemInteger8,...
hItemUnsignedInteger1,...
hItemUnsignedInteger2,...
hItemUnsignedInteger4,...
hItemUnsignedInteger8,...
hItemHour,...
hItemCurrency,...
hItemReal4,...
hItemReal8,...
hItemRealTurbo:
sResultado = sresultado + convert(sValueItem)
CASE hItemText:
sResultado = sResultado + Complete(sValueItem,extractstring(sitem,4),Charact(0))
END
END
sItem = ExtractString(sItemsList,nextRank,CR)
END
sValueItem = ExtractString(sValuesList,nextRank,"/")
i++
END
RESULT sResultado
In the end, only search for the first field on the key index with this function ¿?
Do you see something wrong?
TIA
Pedro Santana Viera
Pedro Santana Viera
Re: Generic search on composite keys and a generic routine... May 23, 2008 10:34AM |
my problem with this kind of search is when the ID (I never do auto ID, but managed ID) has not meaning for the user, and the composite key is the main data to search for (Example: Order number on a Customer with several shops where they are not connected online. We use a counter, say A, B, C, etc... and a correlative number for every counter. Shop 1 orders: A/1, A/2, A/3, etc... . Shop 2 orders: B/1, B/2, B/3, etc... and the like.)If I need to search an order y need to do it with the composite key.Quote
Peter H.
I'm having also composite keys which form a unique identifier of a record in some cases. However, in order to be compliant to relational algebra, those database tables (as every other) also contain a primary unique auto increment identifier (or GUID for cross system uniqueness if required) which is used as foreign key in the other database tables to relate to the table with the composite key.
Pedro Santana Viera
Re: Generic search on composite keys and a generic routine... May 23, 2008 10:47AM |
Peter H.
Re: Generic search on composite keys and a generic routine... May 23, 2008 07:25PM |