/* getCustOrders.p */
DEFINE TEMP-TABLE ttCust NO-UNDO FIELD CustNum AS INTEGER FIELD Name AS CHARACTER INDEX CustNumIdx IS UNIQUE PRIMARY CustNum. DEFINE TEMP-TABLE ttOrder NO-UNDO FIELD OrderNum AS INTEGER FIELD CustNum AS INTEGER INDEX OrderNumIdx IS UNIQUE PRIMARY OrderNum INDEX CustOrdIdx IS UNIQUE CustNum OrderNum. |
DEFINE TEMP-TABLE ttOrderLine NO-UNDO
FIELD OrderNum AS INTEGER FIELD LineNum AS INTEGER INDEX OrderLineIdx IS UNIQUE PRIMARY OrderNum LineNum. DEFINE DATASET dsCustOrd FOR ttCust, ttOrder, ttOrderLine DATA-RELATION CustOrdRel FOR ttCust, ttOrder RELATION-FIELDS (CustNum, CustNum) DATA-RELATION OrdLinesRel FOR ttOrder, ttOrderLine RELATION-FIELDS (OrderNum, OrderNum) NESTED. DEFINE INPUT PARAMETER iCustNum AS INTEGER. DEFINE OUTPUT PARAMETER DATASET FOR dsCustOrd. /* fill dataset and return to caller */ ... |
public string getCustOrders(
System.Nullable<int> iCustNum, out dsCustOrd dsCustOrd) { object[] results = this.Invoke("getCustOrders", new object[] { iCustNum}); dsCustOrd = ((dsCustOrd)(results[1])); return ((string)(results[0])); } ... public partial class dsCustOrd { private dsCustOrdTtCust[] ttCustField; private dsCustOrdTtOrder[] ttOrderField; ... } ... public partial class dsCustOrdTtCust { private System.Nullable<int> custNumField; private string nameField; ... } ... public partial class dsCustOrdTtOrder { private System.Nullable<int> orderNumField; private System.Nullable<int> custNumField; <!-- nested data relation with ttOrderLine --> private dsCustOrdTtOrderTtOrderLine[] ttOrderLineField; ... } ... |
public partial class dsCustOrdTtOrderTtOrderLine {
private System.Nullable<int> orderNumField; private System.Nullable<int> lineNumField; ... } |
using System;
using System.Collections.Generic; using System.Text; using System.IO; namespace getCustOrders { class Program { static void Main(string[] args) { int iCustNum; wsCustOrders.CustOrdersService ws = new wsCustOrders.CustOrdersService(); wsCustOrders.dsCustOrd dsCustOrd; iCustNum = 1; ws.getCustOrders(iCustNum, out dsCustOrd); FileStream fs = new FileStream("getCustOrder.out", FileMode.Create); StreamWriter w = new StreamWriter(fs); //temp-table ttCust for (int i = 0; i < dsCustOrd.ttCust.Length; i++) { w.Write(dsCustOrd.ttCust[i].CustNum); w.Write(dsCustOrd.ttCust[i].Name); w.WriteLine(); } //temp-table ttOrder for (int i = 0; i < dsCustOrd.ttOrder.Length; i++) { w.Write(dsCustOrd.ttOrder[i].CustNum); w.Write(dsCustOrd.ttOrder[i].OrderNum); w.WriteLine(); //nested temp-table ttOrderLine for (int j = 0; j < dsCustOrd.ttOrder[i].ttOrderLine.Length; j++) { w.Write(dsCustOrd.ttOrder[i].ttOrderLine[j].LineNum); w.Write(dsCustOrd.ttOrder[i].ttOrderLine[j].OrderNum); } } w.Close(); } } } |