Defining a procedure to return Order Lines
- Last Updated: March 30, 2020
- 1 minute read
- OpenEdge
- Version 12.2
- Documentation
This section discusses a procedure that retrieves the Order
Lines from the database. This sample procedure is called h-fetchOlines.p.
It takes the current Order Number as an INPUT parameter.
It then defines a temp-table with the fields from the OrderLine table
plus the Item Name and the total Weight for
the quantity ordered. Finally, it defines an OUTPUT parameter
to return the set of Order Lines as a temp-table
to the caller:
|
Notice that you must define the temp-table before you use it in a parameter definition.
Using the INPUT parameter that passed in the Order
Number, the code retrieves all the Order
Lines for that Order. For each
one, it creates a temp-table record.
The procedure then needs to move all the OrderLine fields from the database record into the temp-table. In addition, it must copy the Item Name from the Item table and a calculation of the total weight for the Order Line based on the weight of the item and the quantity ordered.
You could do this with a long ASSIGN statement
that names and assigns each field, but there's a shorter way to
do this, using the BUFFER-COPY statement, as in
this example:
|