Global Variables Used by Data Dictionaries

Several global variables are used with Data Dictionaries.

Err Indicator

The save (Request_Save) and delete (Request_Delete) methods are procedures and therefore do not return a value to indicate if the operation succeeded. Instead, the Err global indicator is set and indicates if these operations succeeded. If Err is False, the operation was a success.

Since the Err indicator is global and easily changed, you should always move the results of this indicator to a local variable or property.

Boolean bError

:

Send Request_Save of hoDDO // will set Err

Move (Err) to bError

 

Property Boolean pbDeleteError

:

Send Request_Delete of hoDDO // will set Err

Set pbDeleteError to (Err)

 

Found Indicator

The various find methods are procedures and do not return a value to indicate if the find was successful. Instead, the Found global indicator is set and indicates if the find succeeded. If Found is True, the find succeeded.

Since the Found indicator is global and easily changed, you should always move the results of this indicator to a local variable or property.

Boolean bFound

:

Send Find of hoDDO EQ 1 // will set Found

Move (Found) to bFound

 

Operation_Mode

Two global integers are maintained during Data Dictionary operations: Operation_Origin and Operation_Mode. These values are maintained by the system and should not be changed. They can be queried and may provide valuable information about a database operation.

Possible Operation_Mode values are:

When a major Data Dictionary operation begins, the DDO will check Operation_Mode to make sure that there is no other data-server operation currently in process. Since DDO operations are not reentrant, the value of Operation_Mode must be Mode_Waiting. Operation_Mode is set based on the type of operation (clearing, finding, saving, deleting). When the operation is complete, Operation_Mode is again restored to Mode_Waiting. The clear and clear-all operations set it to Mode_Clearing or Mode_ClearingAll, respectively. The find and superfind operations set it to Mode_Finding. The save operation sets it to Mode_Saving, and the delete operation sets it to Mode_Deleting.

Operation_Mode is maintained by the system. It can be queried but it should not be changed.

In advanced applications, you can use the value of Operation_Mode to perform custom augmentations. For example, you may discover that you need two backout behaviors, one for saving and one for deleting:

Procedure Backout

    If (Operation_Mode = Mode_Deleting) Begin

        :  // custom backout for deleting

    End

    Else Begin // if not deleting, it must be saving

        :  // custom backout for saving

    End

End_Procedure

See Also

Reentrancy of DDO Methods

 

Operation_Origin

The Operation_Origin indicates which DDO initiated the Data Dictionary operation. It contains the object ID of the originating DDO. The values of Operation_Mode and Operation_Origin are always set at the same time. Operation_Origin is 0 when no data-server operation is in progress.

Operation_Origin was created for the sole purpose of giving the developer more information about a data server operation.

Operation_Origin is maintained by the system. It can be queried but it should not be changed.

In this example, we will use Operation_Origin to make sure that a new record is never saved when that new record is being used as a parent (i.e., the record is not the Main_File of the DDO that received the Request_Save message):

Function Validate_Save Returns Integer

    Integer iError

    Boolean bHasRecord

    Get HasRecord to bHasRecord

    If (Not(bHasRecord) AND Operation_Origin<>Self) Begin

        Send UserError "Can't save this parent record at this time."

    End

    // we only get here if everything is still ok

    Forward Get Validate_Save to iError

    Function_Return iError

End_Function

See Also

Reentrancy of DDO Methods

 

Constrain_Tests_Count and Constrain_Found_Count

Two global integer variables, Constrain_Tests_Count and Constrain_Found_Count, can be used to test if constraints are optimized. Constrain_Tests_Count is incremented after every find and Constrain_Found_Count is incremented if the record is valid (i.e., it meets the constraint requirements). By comparing these two values, you can see if your finds are optimized. The can be tested using the Data Dictionary Inspector.