Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
One cursor from three tables
Message
 
À
25/04/2006 05:34:59
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01116204
Message ID:
01116255
Vues:
15
Did this works for you? The result from this code is not exactly what you want, but check it and tell me if it doesn't what you want. Also have a quesion: is it possible in 2d and 3th fiels to have a Broj that doesn't exists in first file? If so, what you do with it?
CREATE CURSOR Nekret (Broj I, Naziv C(20), KV C(5), Kt_Br I)
CREATE CURSOR Cest   (Broj I, Opis C(5), Area N(10,2))
CREATE CURSOR Zem    (Broj I, Vel C(5))


INSERT INTO Nekret VALUES(1   ,'IME1','02/04',     345091)
INSERT INTO Nekret VALUES(3   ,'IME2','20/04',     300890)
INSERT INTO Nekret VALUES(23  ,'IME3','10/04',     400001)
INSERT INTO Nekret VALUES(1078,'IMEn','10/04',     345091)

INSERT INTO Cest VALUES(23   ,'O1',100.23)
INSERT INTO Cest VALUES(1078 ,'O7',50.56)
INSERT INTO Cest VALUES(1078 ,'o2',11.00)
INSERT INTO Cest VALUES(12087,'kdk',20.00)

INSERT INTO Zem VALUES(1,'xx')
INSERT INTO Zem VALUES(5,'cc')
INSERT INTO Zem VALUES(23,'yy')
INSERT INTO Zem VALUES(1078,'xx')

SELECT Nekret.Broj, Naziv, Kv, Kt_Br, NVL(Cest.Opis, SPACE(5)) AS Opis,;
       NVL(Cest.Area, 0000000000.00) AS Area,;
       NVL(Zem.Vel, SPACE(5)) AS Vel;
       FROM Nekret;
       LEFT JOIN Cest ON Nekret.Broj = Cest.Broj;
       LEFT JOIN Zem  ON Nekret.Broj = Zem.Broj;
ORDER BY Kt_Br, Nekret.Broj;
INTO CURSOR Final_T
BROW NORMAL
>Hi Borislav,
>For each record in first table there are one, n or zero records in second and third table.Field BROJ is common and I need all them in one file. Something like:
>
>1. Nekret
>
>   Broj        Naziv    kV       Kt_br
> ----------------------------------------------
>  00001       IME1     02/04     345091
>  00003       IME2     20/04     300890
>  00023       IME3     10/04     400001
>  .....       ....     .....     ......
>  01078       IMEn     10/04     345091
>
>2.  Cest
>
>    Broj      Opis     Area
> ----------------------------------------
>   00023      O1       100,23
>   01078      O7        50,56
>   01078      o2        11,00
>   .....
>   12087      kdk       20,00
>
>3. Zem
>
>   Broj       Vel
>  -------------------
>  00001       xx
>  00005       cc
>  .....
>  00023       yy
>  .....
>  01078       xx
>
>
>4. Final_T  (ordered on Kt_br, Broj)
>
>   Broj      Naziv     kV       Kt_br     Opis      Area      Vel
>-------------------------------------------------------------------
> 00003                        300890
> 00001     IME1               345091
> 00001                        345091                           xx
> 01078     IMEn               345091
> 01078                                     o7        50,56
> 01078                                     o2        11,00
> 01078                                                         xx
> 00023     IME3               400001
> 00023                                     o1        100,23
> 00023                                                         yy
>
>Regards, gojko
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform