Merging datas and structures

Merging datas and structures

Postby cnavarro » Sat Mar 26, 2016 2:02 pm

In the Harbour group users

https://groups.google.com/forum/?fromgr ... Tisk_kIsXk
Code: Select all  Expand view


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
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Return to Utilities / Utilidades

Who is online

Users browsing this forum: No registered users and 6 guests