Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
OneToMany Relation
Message
De
29/10/1999 05:26:45
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
28/10/1999 23:52:46
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00282854
Message ID:
00283673
Vues:
11
Alvin,
For a quick start get all the fields in both tables. Say your tables and relation look like this :
Customer +-< Orders
* Your setup
use orders order tag cust_code
select 0
use customer
set relation to cust_code into orders

* SQL for report
select * from Customer a ;
  left outer join Orders b ;
  on a.Cust_code = b.Cust_code ;
  order by Company, order_date ;
  into cursor crsReport
If we assume only cust_code fieldname exists in both tables and rest are unique, there would be cust_code_a and cust_code_b fields in cursor. Both have the same value that you would consider as cust_code (this is only imporatant if you use cust_code field in report to show or for grouping).
Cetin




>Thank you very much Cetin & Cindy for your help.
>
>I have another question on the SQL query statement.
>For instant I need to link the Parent.field (eg customer code)
>to the Customer table to get Customer Name and a few more of
>these type of links. How could I incoporate it into the SELECT
>statement below? Thank you once again.
>
>>Alvin,
>>
>>This is the best way to do reports: SELECT the data just as you would like it to appear in your report into a CURSOR. (Make sure the cursor is in the current work area.) Don't put the CURSOR or any other tables in the report's data environment. Refer to the field names in the report by field name only - no table name.
>>
>>
>>cAlias = ALIAS()
>>SELECT Parent.SomeField, Child.SomeOtherField ;
>>    FROM Parent LEFT JOIN Child ;
>>    ON Parent.Id = Child.Id ;
>>    INTO CURSOR Temp
>>
>>REPORT FORM MyReport TO PRINTER NOCONSOLE
>>SELECT (cAlias)
>>
>>
>>Report fields SomeField and SomeOtherField (not Temp.SomeField, Temp.SomeOtherField)
>>
>>Then you can keep your grids working properly.
>>
>>
>>>I have set the a Relation property of "OneToMany" to .T.
>>>in order to print a Header & Detail report in the
>>>Report's dataenviornment.
>>>
>>>After the report has printed and it goes back to the main
>>>application, which has 2 grids that display Header and
>>>Details, the Header Grid got hay-wire with a few lines
>>>of record displaying ******* in the fields.
>>>
>>>But if I set the "OneToMany" Relation to .F., then there
>>>isn't any problem. But the Report would only print one
>>>line of the Detail record. Any suggestions? Thanks.
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform