Determine Last

Syntax

DETERMINE LAST <iterator> [ SECURE | KEYONLY ] [ GS status ]
<iterator> := <object> | <profile>
<object> := object_name( argument [ ,...n ] )
<profile> := object_name.profile_name( argument [ ,...n ] )

Parameters

Determine Last can be abbreviated as DT Last.

Note: The Secure and KeyOnly parameters are not applicable for external classes with persistent members.

Description

The Determine Last logic command reads a single persistent class record that matches specified key values into memory from the database. The data read from the database is stored in the instance of the persistent class specified in the command. If there is no match, the preceding record is read instead. You can also use an external class with persistent members to read a record from an external data source.

Set the segment's Integrity property to true or specify the Secure command option if using the Determine Last logic command in a running balance or equivalent situation. This ensures that the record retrieved is always the last record.

Refer to Determine Variants for more information on the Determine logic command.

Example

In this example, for each product, the report lists the ProductID and ProductName, along with the details of the last sale that has occurred for that product. The Determine Last command is used to retrieve the last SaleEvent transaction for the ProductID specified, moving the additional details into the ProductDetail frame and printing. 

Since the P_DateTime profile has four keys, corresponding data must be provided for the Determine Last command to use.  Product.ProductID is provided, corresponding to the first key of the profile, and designating what SaleEvent record needs to be retrieved – high values (since the keys of this profile are in ascending order) are provided to correspond to the secondary keys.

Determine Actual Product.P_ProductName 
     ProductDetail.ProductID    := Product.ProductID  
     ProductDetail.ProductName  := Product.ProductName
     Determine Last SaleEvent.P_DateTime                      \
               (Product.ProductID, G_Nines, Glb.High, G_Nines)
     If (SaleEvent.ProductID = Product.ProductID)
            ProductDetail.CustomerID := SaleEvent.CustomerID
            ProductDetail.Quantity   := SaleEvent.SoldQuantity
            ProductDetail.Print()
     Else
            ProductDetail.CustomerID  :=  “NONE”
            ProductDetail.Quantity    :=  0      
     End
 End

For this example, some of the output from the report is illustrated, in product name order:

Product Name

Product ID

Last Sold Quantity

Customer ID

CatBathSoap

7

0

None

Chips for cats

2

14

1

DogBelt

6

0

None

Gimborn R-7

3

0

None

KittenCaps

4

30

2

Leather Belt

9

0

None