You are here: Function Reference > Alphabetical Listing > D > DBFind

DBFind

Use this procedure/function to retrieve the first record from a database table which satisfies the key criteria.

Syntax

DBFind (Table, Variable, KeyName1, KeyValue1, KeyName2, KeyValue2,...)

Parameter

Description

Table

Enter the name of an open table.

Variable

Enter the name of a DAL variable to associate with the record fields retrieved by the procedure. The default is Table.

KeyName,

KeyValue, ...

Each KeyName specifies a column to search. For some database handlers, it may be a case-sensitive.

Each KeyValue is the value of the corresponding KeyName for which to search. For some database handlers, this may be a case-sensitive comparison.

At least one pair of KeyName/KeyValue are required.

The system optionally returns one (1) on success or zero (0) on failure.

If the Variable parameter has not been defined, it will be created. You can access the table record fields assigned this prefix using the dot (.) operator. For example, assume Record is a prefix variable and the table record contains the columns Company, Lob, and Policynum. The values of the individual fields would be referenced as Record.Company, Record.Lob, and Record.Policynum, respectively.

The variable names appended with a prefix are taken from the DFD file associated with the table you specified in the Table parameter or by using the column names found in the table if there is no format file associated with the table.

Note The variable name is truncated to eight characters when you use a long name. Variable names are limited to eight characters if you do not use the DBPrepVars procedure and nine characters if you do. A variable name plus the stem name cannot exceed 32 characters.

This procedure supports a variable number of parameters. As many KeyName and KeyValue combinations required to identify the specific keyed record to retrieve may be defined as parameters. If the record cannot be retrieved, possible causes include:

Example

Here is an example:

Procedure

Result

Explanation

DBFind( "APPIDX", "RECORD", "Company","Oracle", "Lob", "DM" )

1 or 0

Assuming that the APPIDX table has columns named Company and Lob, and that these columns are a key, the first record containing "Oracle" and "DM" in the appropriate column will be retrieved and associated with the prefix variable RECORD.

See also