Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Parent/Child/and Grandchild projects into a report
Message
 
À
10/04/2009 13:01:39
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de rapports & Rapports
Divers
Thread ID:
01393750
Message ID:
01394179
Vues:
61
This message has been marked as the solution to the initial question of the thread.
>Yes, I created the problem with the first select when I set the rtp_id = 0.
>
>Here is some data from the TIP table.
>TIP_ID RTP_ID ST_NAME
>10.3 40.08 TIPProject1
>12.03 42.03 TIPProject2
>13.03 40.08 TIPProject3
>In this table the RTP_ID serves the same function as the PARENTPROJECT field in RTP table. That is it identifies the parent (IN THE RTP table that the TIP project belongs to.
>
>Here is some data from the RTP table.
>RTP_ID PARENTPROJECT ST_NAME
>40.08 blank RTPProject1
>42.03 40.08 RTPProject2
>10.06 40.08 RTPProject3
>2.08 42.03 RTPProject4
>
>Here is the result we need from the first select in order to make the second select work.
>RTP_ID PARENTPROJECT ST_NAME
>40.08 blank RTPProject1
>42.03 40.08 RTPProject2
>10.06 40.08 RTPProject3
>2.08 42.03 RTPProject4
>pseudoRTPid1 40.08 TIPProject1
>pseudoRTPid2 42.03 TIPProject2
>pseudoRTPid3 40.08 TIPProject3
>
>The pseudoRTPid needs to be unique in the result cursor and must not duplicate any number that may exist as an RTP_ID in the RTP table. Hmmm . . . maybe I could use the tip_id + .001? I'll give that a try.


How about:
CREATE CURSOR Tip (Tip_Id N(5,2), Rtp_Id N(5,2), St_Name C(20))
CREATE CURSOR Rtp (Rtp_Id N(5,2),PARENTPROJECT N(5,2), St_Name C(20))
INSERT INTO Tip VALUES (10.30, 40.08, "TIPProject1")
INSERT INTO Tip VALUES (12.03, 42.03, "TIPProject2")
INSERT INTO Tip VALUES (13.03, 40.08, "TIPProject3")

INSERT INTO Rtp VALUES (40.08,     0, "RTPProject1")
INSERT INTO Rtp VALUES (42.03, 40.08, "RTPProject2")
INSERT INTO Rtp VALUES (10.06, 40.08, "RTPProject3")
INSERT INTO Rtp VALUES ( 2.08, 42.03, "RTPProject4")


SELECT CAST(99999999+Tip_Id as N(14,2)) AS Rtp_Id,;
       Rtp_Id                           AS PARENTPROJECT,;
       St_Name;
FROM Tip;
UNION ALL;
SELECT CAST(Rtp_Id as N(14,2)) AS Rtp_Id,;
       PARENTPROJECT,;
       St_Name;
FROM Rtp;
INTO CURSOR crsTest
BROWSE NORMAL
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