OpenAsOfDate method: Tree class

Syntax

OpenAsOfDate(SetID, UserKeyValue, TreeName, AsOfDate, BranchName, Update)

Description

The OpenAsOfDate method operates similarly to the Open method and uses the same parameters except that instead of requiring the EffDt parameter, OpenAsOfDate uses a less restrictive AsOfDate parameter. The OpenAsOfDate method opens the most recent tree based on AsOfDate. If AsOfDate is not supplied, the current date is used.

Note:

Because EFFDT is a key field for a tree definition, an exact match is required to open a tree with the Open method.

The OpenAsOfDate method can be used only with a closed tree; it cannot be used on an open tree. You cannot read or set any properties of a tree until after you open it. When you open a tree, you can specify whether you want to open it for update, or in read-only mode, with the Update parameter. If you try updating or writing to a tree opened in read-only mode, you receive an error.

Parameters

Parameter Description

SetID

Specify the table indirection key for the tree. This parameter takes a string value. If the tree structure the tree is based on has its IndirectionMethod specified as "S", you must specify a SetID.

If the tree structure doesn’t have its IndirectionMethod specified as "S", you must enter a Null string (that is, two quotation marks with no blank space between them ("")) for this parameter.

UserKeyValue

Specify the User Key value for the tree. This parameter takes a string value. If the tree structure the tree is based on has its IndirectionMethod specified as "U" or "B", you must specify a User Key Value.

If the tree structure doesn’t have its IndirectionMethod specified as "U" or "B", you must enter a Null string (that is, two quotation marks with no blank space between them ("")) for this parameter.

TreeName

Specify the name for the tree. This parameter takes a string value.

AsOfDate

Specify the “as-of-date” for the tree as a string. The format must be in the correct format for the database platform the code is executing on.

If this parameter is not supplied, then the current date is used.

If more than one tree matches the SetID, UserKeyValue, TreeName, and BranchName parameters, the tree with most recent effective date less than or equal to the as-of-date is opened.

BranchName

This parameter is required, but it is unused in this release. You must enter a Null string (that is, two quotation marks with no blank space between them ("")) for this parameter.

Update

Specify if you want to open the tree for update or in read-only mode. This parameter takes a Boolean value. Values for Update are:

  • True: open tree structure in update mode (read/write).

  • False: open tree structure in read-only mode.

If you try updating or writing to a tree structure opened in read-only mode, you receive an error.

Returns

An integer: 0 if opened successfully.

Example

The following example opens a tree object with most recent effective date matching the other tree criteria. Then, the program tests to see if the tree was actually opened:

&ret = &MyTree.OpenAsOfDate("QEDM1","","PERSONAL_DATA", "", "", True);

If &ret = 0 Then 
   /* normal processing */ 
Else 
   /* error processing tree isn't open */ 
End-if;

Related Topics