Ayuda juntar ficheros.dbf con JOIN

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
mustafa
Posts: 1013
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Been thanked: 210 times
Contact:

Ayuda juntar ficheros.dbf con JOIN

Post by mustafa »

Necesito Ayuda con JOIN
tengo dos bases de datos y no se juntan completamente

una STOCK.DBF INDEXADA POR REF
REF PRODUCTO TIPO PRECIO
N C C N
1 FRENOS GASOLINA 15.50
2 MORDAZA GASOLINA 16.50
3 CABLE GASOIL 23.74
4 BOMBILLAS GASOIL 25.74

la segunda base PED_CLI INDEXADA POR REF
REF MATRICULA CANTIDAD FECHA_S
N C N D
1 2345-BGH 4 01/03/2009
2 4563-CGH 5 01/03/2009
3 6754-HFG 2 15/03/2009

Tanto EN CLIPPER COMO EN dBfast
la union de las dos bases de datos en una tercera
hago lo siguiente y funciona
*------------------------------------------------------------------*
USE PED_CLI
INDEX ON ref TO PED_NUM
USE STOCK
INDEX ON ref TO STO_NUM
CLOSE DATABASES
ERASE PED_STO.DBF

SELECT 1
USE PED_CLI INDEX PED_NUM ALIAS aa

SELECT 2
USE STOCK INDEX STO_NUM
JOIN WITH aa TO PED_STO FOR REF=aa->REF
*-----------------------------------------------------------------*
la nueva base PED_STO tiene que tener los campos
REF PRODUCTO TIPO PRECIO MATRICULA CANTIDAD FECHA_S
1 FRENOS GASOLINA 15.50 2345-BGH 4 01/03/2009
2 MORDAZA GASOLINA 16.50 4563-CGH 5 01/03/2009
3 CABLE GASOIL 23.74 6754-HFG 2 15/03/2009
pero compilado con Xharbour modo consola o en Minigui
la base PED_STO solo sale los campos

REF PRODUCTO TIPO PRECIO

Un saludo

Need Help JOIN
I have two databases and did not fully meet

Indexed by a STOCK.DBF REF
REF PRODUCT TYPE PRICE
N N C C
1 BRAKE PETROL 15.50
2 Gag PETROL 16.50
3 CABLE GASOIL 23.74
4 BULBS GASOIL 25.74

second baseman PED_CLI INDEX BY REF
REF REGISTRATION NUMBER DATE_S
N C N D
1 2345-BGH 4 01/03/2009
2 4563-CGH 5 01/03/2009
3 6754-HFG 2 15/03/2009

Both CLIPPER IN DURING dBfast
the union of the two databases in third
I do the following functions
*------------------------------------------------- -----------------*
USE PED_CLI
INDEX ON TO PED_NUM ref
USE STOCK
INDEX ON TO STO_NUM ref
CLOSE DATABASES
ERASE PED_STO.DBF

SELECT 1
PED_CLI USE INDEX ALIAS PED_NUM aa

SELECT 2
USE STOCK INDEX STO_NUM
TO JOIN WITH PED_STO FOR REF aa = aa-> REF
*------------------------------------------------- ----------------*
PED_STO the new base has to have the fields

REF PRODUCT TYPE PRICE REGISTRATION NUMBER DATE_S
N N C C C N D
1 BRAKE PETROL 15.50 2345-BGH 4 01/03/2009
2 Gag PETROL 16.50 4563-CGH 5 01/03/2009
3 CABLE GASOIL 23.74 6754-HFG 2 15/03/2009
but compiled with xHarbour console mode or in MiniGui
Based PED_STO only leaves the field
REF PRODUCT TYPE PRICE

Greetings I do not speak English

User avatar
esgici
Posts: 4538
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 410 times
Been thanked: 118 times
Contact:

Post by esgici »

Hola ( merhaba ) Mustafa, Welcome

İt's difficult understanding your question by your post.

Could you send your tables and .prgs by attached .zip file ?


Regards

--

Esgici
Viva INTERNATIONAL HMG :D

User avatar
mustafa
Posts: 1013
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Been thanked: 210 times
Contact:

Post by mustafa »

USE PED_CLI
INDEX ON ref TO PED_NUM
USE STOCK
INDEX ON ref TO STO_NUM
CLOSE DATABASES
ERASE PED_STO.DBF

SELECT 1
USE PED_CLI INDEX PED_NUM ALIAS aa

SELECT 2
USE STOCK INDEX STO_NUM
JOIN WITH aa TO PED_STO FOR REF=aa->REF

1º file STOCK.DBF index by REF
REF PRODUCT TYPE PRICE
N C C N

2º file PED_CLI index by REF
REF MATRICULA CANTIDAD FECHA_S
N C N D
N= Numeric
C= Alfa_Numeric
D= Date

JOIN by CLIPPER or dBfast
New file PED_STO

REF PRODUCT TYPE PRICE MATRICULA CANTIDAD FECHA_S


JOIN xHARBOUR console or Minigui

file REF PRODUCT TYPE PRICE

missing the rest of records
un saludo

User avatar
esgici
Posts: 4538
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 410 times
Been thanked: 118 times
Contact:

Post by esgici »

Hola Mustafa

I'm not sure that I understood your question. Yet look at above test prg ( console mode only ).

Code: Select all

PROC Main()

  SET DATE GERM
  
  MakUsFils()

  SELE STOK
  
  JOIN WITH TRNS TO "PED_STO.DBF" FOR STOK->REF == TRNS->REF ;
          FIELDS REF, PRODUCT, TYPE, BULBS, TRNS->REF, TRNS->REGIST, TRNS->NUMBER, TRNS->DATE 

  USE PED_STO NEW
  BROWSE()
   
RETU // Main()


PROC MakUsFils()

   LOCAL aStkStru := { { "REF",     "N",  2, 0 },;
                       { "PRODUCT", "C", 10, 0 },;  
                       { "TYPE",    "C", 10, 0 },;  
                       { "BULBS",   "N", 10, 2 } },;  
         aTrnStru := { { "REF",     "N",  2, 0 },;
                       { "REGIST",  "C", 10, 0 },;  
                       { "NUMBER",  "N",  2, 0 },;  
                       { "DATE",    "D", 10, 0 } },;  
         aSTkData := { { 1, "BRAKE", "PETROL", 15.50 },;
                       { 2, "Gag",   "PETROL", 16.50 },;
                       { 3, "CABLE", "GASOIL", 23.74 },;
                       { 4, "BULBS", "GASOIL", 25.74 }},;
         aTrnData := { { 1, "2345-BGH", 4, CTOD("01/03/2009") },;
                       { 2, "4563-CGH", 5, CTOD("01/03/2009") },;
                       { 3, "6754-HFG", 2, CTOD("15/03/2009") } }
                       
    LOCAL a1
    
    IF FILE( "STOK.DBF" )
       USE STOK ALIAS STOK INDEX STO_NUM
    ELSE                     
       DBCREATE("STOK", aStkStru, ,.T., "STOK" )
       INDEX ON REF TO STO_NUM 
       FOR EACH a1 IN aSTkData 
          DBAPPEND()
          AEVAL( a1, { | x1, i1 | FIELDPUT( i1, x1 ) } )   
       NEXT
    ENDIF   
    
    IF FILE( "PED_CLI.DBF" )
       USE PED_CLI ALIA TRNS INDEX PED_NUM NEW
    ELSE          
       DBCREATE( "PED_CLI", aTrnStru, ,.T., "TRNS" )
       INDEX ON REF TO PED_NUM
       FOR EACH a1 IN aTrnData
          DBAPPEND()
          AEVAL( a1, { | x1, i1 | FIELDPUT( i1, x1 ) } )   
       NEXT
    ENDIF
    
RETU // MakUsFils()
By the way Harbour doc says :

When the FIELDS clause is omitted, all fields from the primary workarea are included in the target database file.

Saludos

--

Esgici
Viva INTERNATIONAL HMG :D

User avatar
mustafa
Posts: 1013
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Been thanked: 210 times
Contact:

Post by mustafa »

Hellow Esgici
Thanks for taking your time to my problem
I dont know how to send an attachment in my program files to see what happens
Both Clliper in dBfast, is perfect.
What I want is a file that is called STOCK.DBF which has a field that is called
REF and another file called PED_CLI.DBF are assembled into a new file that is
call PED_STO.DBF
Your example works out fine but the files are empty STOCK.DBF and PED_CLI instead
File PED_STO goes well, but if the two files and STOCK PED_CLI have data
PED_STO the file goes wrong.
Sorry I dont speak English I am translating by program
Salam

User avatar
esgici
Posts: 4538
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 410 times
Been thanked: 118 times
Contact:

Post by esgici »

Aleyna ve aleykum salam Mustafa
mustafa wrote: Your example works out fine but the files are empty STOCK.DBF and PED_CLI instead
File PED_STO goes well, but if the two files and STOCK PED_CLI have data
PED_STO the file goes wrong.
For me PED_STO is OK when other two file have data.

It's builded by JOIN command with 8 fields and 3 records.

So, could you explain what is wrong ?

You can send you .prg and .dbf files to my e-mail adress : esgici @ gmail.com


maassalame

--

Esgici
Last edited by esgici on Sat Mar 21, 2009 10:00 pm, edited 1 time in total.
Viva INTERNATIONAL HMG :D

User avatar
mustafa
Posts: 1013
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Been thanked: 210 times
Contact:

Post by mustafa »

Hello Esgici
give you two folders and see that are different
see the results of the jpg images
in your records are only 3 and is repeated REF
in my post 5 entries.
Salam Mustafa Lopez

Post Reply