RowId Type

The RowId type is used to declare variables that store a unique identifier for a specific row (aka record) of a database table.

RowId variables can be used to store record identifiers and to find records identified by a RowId value.

Example

 

Open Customer

 

RowId[] riCustomers    // array of RowId's

Integer i iSize

 

// loop through the customer table and store each row's ID

Repeat

    Find GT Customer by 1

 

    // store the RowId.

    If (Found) Begin

        Move (SizeOfArray(riCustomers)) to iSize

        Move (GetRowID(Customer.File_Number)) to riCustomers[iSize]

    End

Until (not(Found))

 

// Now loop through the RowId's and find the associated row.

Move (SizeOfArray(riCustomers)) to iSize

 

For i From 0 to (iSize – 1)

    // find the customer for this row.

    If (FindByRowID(Customer.File_Number, riCustomers[i])) Begin

        Showln Customer.Name

    End

Loop

 

The above example loads each row of the customer table and stores the RowId in an array of type RowId. In the second loop, the array is iterated and each stored RowId is used to locate the corresponding row in the customer table.

RowId Composition

The data that forms the RowId of a particular table is specific to the design of that table. For example in the simple case it may be composed of an integer value, or it may be a composition of an integer, a string and a date value, or it may be a number a Boolean and a date, etc.

In general, the format of the data that is stored in a RowId is internal and cannot be manipulated directly.

Manipulating RowIDs

All  manipulation of RowIDs is performed using RowId functions. Using the RowId functions you can:

Retrieve a RowId

Example:

Open  Customer

RowId riCustomer

Boolean bFound

 

Find GT Customer by 1

Move (GetRowID(Customer.File_Number)) To riCustomer

 

Find a Row

Example:

Move (FindByRowID(Customer.File_Number, riCustomer)) To bFound

The FindByRowID function loads the row into the customer table's buffer that corresponds with the RowId value stored in riCustomer.

Clear a RowId

Example:

Move (NullRowID()) To riCustomer

After calling the NullRowID function riCustomer contains the null RowId.

Test for a Null RowId

Example:

If (Not(IsNullRowID(riCustomer))) Begin

    Move (FindByRowID(Customer.File_Number, riCustomer)) To bFound

End

 

Test for Equality

Example:

RowId riBestCustomer

//..

Move (GetRowID(Customer.File_Number)) To riCustomer

 

If (IsSameRowID(riCustomer, riBestCustomer)) Begin

    Send Stop_Box ("Best customer is:" * Customer.Name) ""

End

 

Serialize a RowId

Example:

String sRowID

 

Move (SerializeRowID(riCustomer)) To sRowID

 

De-serialize a RowId

Example:

Move (DeSerializeRowID(sRowID)) To riCustomer

Web applications and web services use serializing and de-serializing to transform RowIDs into and out of a format that can be used in URLs, Web pages and Web Services.

Web Applications

Array Properties are supported in Web Applications (see WebSet for details), with the exception of multi-dimensional arrays and RowId.

More Information

For more information regarding RowIDs refer to: The RowId command and the RowId Helper Functions.

For information regarding RowIDs and data dictionaries, refer to the DataDictionary class.