Stupid question about temp index ...

Stupid question about temp index ...

Postby Rimantas » Sun May 10, 2009 6:11 pm

Hi ,

Maybe this can be done what I wanna ... :) There are 2 tables ( DBFCDX RDD ) - 1-st header of documents and 2-nd - variuos items in documents . The relation between them is Doc_Id . The first table have field DocDate . To speed some search of movement of needfull item in needful month it can be better in this way - DocItms->ITEM + dtos( DocJourn->DocDate ) ... But I don't - it's possible or not . At this time I'm running seacrh through period of documents and looking inside DocItms ( dbseek( DocJourn->Doc_Id + cNeedFullItem ) ...

Many thanks in advance ...
Rimantas U.
User avatar
Rimantas
 
Posts: 437
Joined: Fri Oct 07, 2005 12:56 pm
Location: Utena , Lithuania

Re: Stupid question about temp index ...

Postby codemaker » Mon May 11, 2009 1:33 am

Rimantas,

Did you think about using RELATIONS ?

Boris
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: Stupid question about temp index ...

Postby Rimantas » Mon May 11, 2009 6:16 am

codemaker wrote:Rimantas,

Did you think about using RELATIONS ?

Boris


As I know , without RELATION it can't to do . Question here - how good speed will be relating two tables and it's possible to build temp index on this related tables ?
Rimantas U.
User avatar
Rimantas
 
Posts: 437
Joined: Fri Oct 07, 2005 12:56 pm
Location: Utena , Lithuania

Re: Stupid question about temp index ...

Postby Carlos Mora » Wed May 13, 2009 1:42 pm

Hi Rimantas,

I'm doing exactly what you ask. I have the same problem: a table with clients(Id PK) and a table with TaxForms ( TaxId, Period, ClientID ). I have to show a browse with all the forms for a given Tax and Period... but the browse should be ordererd by ClientId OR Clients->ClientName. So I build a new pair of temporary indexes using FOR ... WHILE to make them faster. Following the piece of code.

Code: Select all  Expand view
 

 Select M303

   Set Relation To Field->CodEmp Into Empresas

   // Index On Field->CodEmp Tag 'TCodEmp' For Field->Ejercicio == cAnio Temporary
   ordCondSet( "Field->Ejercicio == '"+cAnio+"'.and. Field->Periodo == '"+cPeriodo+"'", &( "{|| Field->Ejercicio == '"+cAnio+"'.and. Field->Periodo == '"+cPeriodo+"'}"),,,,, RECNO(),,,,,,,,,,, .T.,, )
   ordCreate(, "TCodEmp", "Field->CodEmp", {||Field->CodEmp}, )

   // Index On Field->Empresas->Empresa Tag 'TEmpresa' For Field->Ejercicio == cAnio Temporary
   ordCondSet( "Field->Ejercicio == '"+cAnio+"'.and. Field->Periodo == '"+cPeriodo+"'", &( "{|| Field->Ejercicio == '"+cAnio+"'.and. Field->Periodo == '"+cPeriodo+"'}"),,,,, RECNO(),,,,,,,,,,, .T.,, )
   ordCreate(, "TEmpresa", "Empresas->Empresa", {||Empresas->Empresa}, )

   Go Top

 


This works OK. I have used the functional form of INDEX because I replaced the variable part of the filter expresion with constants.

Hope this helps,

Carlos.
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Carlos Mora
 
Posts: 989
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: Stupid question about temp index ...

Postby Rimantas » Thu May 14, 2009 8:56 am

Carlos Mora wrote:Hi Rimantas,

I'm doing exactly what you ask. I have the same problem: a table with clients(Id PK) and a table with TaxForms ( TaxId, Period, ClientID ). I have to show a browse with all the forms for a given Tax and Period... but the browse should be ordererd by ClientId OR Clients->ClientName. So I build a new pair of temporary indexes using FOR ... WHILE to make them faster. Following the piece of code.
...
Hope this helps,

Carlos.



Many thanks to you , Carlos ! A ver good sample !
Rimantas U.
User avatar
Rimantas
 
Posts: 437
Joined: Fri Oct 07, 2005 12:56 pm
Location: Utena , Lithuania


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 73 guests