get

Examples


The get statement retrieves a record from the table without locking the record. You can’t change the data in a record that has been retrieved with the get statement.

Syntax

get {next | prev | first | last} table table_name {by key_name | by number expr}{, refresh}{with(hint)}

Parameters

next | prev | first | last – Identifies which record you wish to retrieve.

If none of these keywords are included, the record that matches the key value in the table buffer will be retrieved. The next keyword will retrieve the record that follows the key value currently in the table buffer. The prev keyword will retrieve the record preceding the key value in the table buffer. The first keyword will retrieve the first record in the table or range. The last keyword will retrieve the last record in the table or range.

table table_name – The name of the table containing the record to read.

by key_name | by number expr – Identifies the key to use to locate the record to be retrieved. If one of these parameters isn’t included, the first key will be used.

You can identify the key by its name or by the key number. In the by key_name parameter, key_name is the key’s technical name. In the by number expr parameter, expr is an integer containing the number of the key, determined by its position in the table definition. For instance, the third key created can be identified by the number 3, and so on.

refresh – This keyword only applies when a SQL database type is used. It indicates that the cursor and client-side buffer will be refreshed, so that they’ll contain the most current data from the table before the get statement is used. Even if the get attempt fails, the refresh will occur.

If the Pervasive.SQL or c-tree Plus database types are used, the refresh keyword will be ignored. It will not affect your application in any way.


with(hint) – This keyword applies only when a SQL database type is used. It allows you to supply an optimizer hint to control how the SQL Server query optimizer works. In this version of Dexterity, the following optimizer hints are supported:

[spacer]

Hint

Description

NOLOCK

Specifies that the SQL Server should not issue a shared lock and to disregard any existing exclusive locks on the row being read. This is referred to as a “dirty read”.

FORCEINDEX

Causes the SQL Server to disregard the query plan it generated and use the index specified by the get statement. If no key has been specified for the get statement, the primary key will be used.

If a clustered index exists for the table, specifying that the get statement use key 0 forces a clustered index scan. If no clustered index exists, using key 0 will force a table scan.


Comments

The values of the key fields should be set in the table buffer before the get statement is issued. You don’t need to set any fields in the table buffer to retrieve the first or the last record in a table.

The get statement fills only the table buffer. To transfer information to the window so the information can be displayed, use a copy from table statement. To transfer a single field of information from the table buffer to the window, use the set statement.

If the specified table isn’t open, the get statement will open it.

The err() function or the check error statement can be used after the get statement to ascertain whether the operation was successful or to handle errors that may have occurred.


Documentation Feedback