FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index Utilities / Utilidades Merging datas and structures
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Merging datas and structures
Posted: Sat Mar 26, 2016 02:02 PM
In the Harbour group users

https://groups.google.com/forum/?fromgr ... Tisk_kIsXk
Code (fw): Select all Collapse
DBSTRUMERGE("mpdbtmp",{ "plos2016", "poc2016", "ras2016", "rass2016", "razm2016", "vra2016", "vras2016"},.t.)

***********************************************************************
FUNCTION DBSTRUMERGE(cNewbase,aBases,mergeData)
LOCAL i, j, k, aDbf:={}, aDbftmp:={}, aErrFields:={},dSelect:=SELECT()

FOR i=1 TO LEN(aBases)
       DBUSEAREA(.T.,,aBases[i],,.t.)
       IF i=1 ; aDbf:=DBSTRUCT() ; LOOP ; ENDIF
       aDbftmp:=DBSTRUCT()
       FOR j=1 TO LEN(aDbftmp)
              IF (k:=ASCAN(aDbf,{| x | x[ 1 ] == aDbftmp[j,1] } )) <> 0
                  IF aDbf[k,2]<>aDbftmp[j,2] .OR. aDbf[k,3]<>aDbftmp[j,3] .OR. aDbf[k,4]<>aDbftmp[j,4] 
                      AADD(aErrFields,{ aBases[i],  aDbf[k,1] })
                 ENDIF
             ELSE   
                 AADD(aDbf, aDbftmp[j])
             ENDIF   
      NEXT
      DBCLOSEAREA()
NEXT    

DBCREATE(cNewbase, ASORT(aDbf,,, {| x, y | x[ 1 ] < y[ 1 ] } ) )    

IF PCOUNT()=3
    DBUSEAREA(.T.,,cNewbase,,.t.)
    FOR i=1 TO LEN(aBases)
           APPEND FROM (aBases[i]) 
    NEXT
    DBCLOSEAREA()
ENDIF

RETURN aErrFields


//By Zoran Sibinovic


No lo he probado aun, pero me ha parecido interesante

I have not tried yet, but I found interesting

Regards
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces

Continue the discussion