Feedback
Did this article resolve your question/issue?

   

Article

How to specify which table a field's data comes from in a DATA-SOURCE object?

Information

 
TitleHow to specify which table a field's data comes from in a DATA-SOURCE object?
URL Namehow-to-specify-which-table-a-field-s-data-comes-from-in-a-data-source-object
Article Number000138600
EnvironmentProduct: OpenEdge
Version: All Supported Versions
OS: All Supported Platforms
Question/Problem Description
Is it possible to specify which source table the value of a field in the target TEMP-TABLE comes from when filling the TEMP-TABLE using DATA-SOURCE objects?

Scenario:
  • Need to combine the data from two tables in a TEMP-TABLE, like perhaps a customer record with multiple shipping destinations (e.g. Customer >> ShipTo)
  • Both tables have address fields in them but we want the data from the record that contains the shipping destination (e.g. ShipTo.Address, ShipTo.State, ShipTo.City, etc)
  • Using a QUERY defined against both tables, and a DATA-SOURCE object to fill the temp-table
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
The BUFFER object method ATTACH-DATA-SOURCE() provides the Pairs List option, which provides the ability to specify which source table the data for the State field in the target TEMP-TABLE comes from.

Example:
DEFINE TEMP-TABLE ttOrder    NO-UNDO LIKE Order.
DEFINE TEMP-TABLE ttCustInfo NO-UNDO LIKE Customer.

DEFINE DATASET dsShipOrder FOR ttOrder, ttCustInfo
    DATA-RELATION relOrdCust FOR ttOrder, ttCustInfo
        RELATION-FIELDS ( CustNum, CustNum ).

DEFINE QUERY qCustQry FOR Customer, ShipTo SCROLLING.

DEFINE DATA-SOURCE srcOrder    FOR Order.
DEFINE DATA-SOURCE srcCustInfo FOR QUERY qCustQry.

BUFFER ttOrder:ATTACH-DATA-SOURCE(DATA-SOURCE srcOrder:HANDLE).
DATA-SOURCE srcOrder:FILL-WHERE-STRING = "WHERE Order.OrderStatus NE ~"Shipped~"".

BUFFER ttCustInfo:ATTACH-DATA-SOURCE(DATA-SOURCE srcCustInfo:HANDLE,
                                     "ttCustInfo.Address,ShipTo.Address,"       + 
                                     "ttCustInfo.Address2,ShipTo.Address2,"     +
                                     "ttCustInfo.City,ShipTo.City,"             + 
                                     "ttCustInfo.State,ShipTo.State,"           + 
                                     "ttCustInfo.PostalCode,ShipTo.PostalCode," +
                                     "ttCustInfo.Phone,ShipTo.Phone").
QUERY qCustQry:QUERY-PREPARE("FOR EACH Customer" + 
                             " WHERE Customer.CustNum EQ ttOrder.CustNum," +
                             " EACH ShipTo WHERE ShipTo.CustNum EQ Customer.CustNum").

DATASET dsShipOrder:FILL().

 
Workaround
Notes
Last Modified Date2/26/2019 5:45 PM
Attachment 
Files
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.