isDefined Method

Class: Db

Description

This method returns an indication of whether a record exists in the database.

As of Profile v6.3, this method supports lowercase variables, object.property, and system variables within the host variable syntax. PSL maps these variables and object references into uppercase host variables.

When using the classNew parameter for the Db.getRecord method, you can avoid a series of method usages such as:

Db.isDefined
If Yes, then use Db.getRecord.
If no, then use Class.new to instantiate the record.

This should reduce the valid uses of the Db.isDefined method. Review each use of Db.isDefined to ensure that it is valid.

Syntax

Db.isDefined(literal String tableName,literal String whereClause,

Number matchCount)

Parameters

tableName

A valid database table name.

whereClause

An SQL WHERE clause. For backward compatibility, a comma-separated list of access keys for the table is also acceptable. The list will be translated into the corresponding whereClause.

matchCount

The number of records matching the specified table and access keys (i.e., whereClause). When using this parameter, it is not necessary to specify all the keys. In addition, non-key columns can also be specified in the whereClause parameter.

If matchCount is not specified, the default is 1.

Returns

1 if at least matchCount distinct records satisfy the whereClause.
0 if less than the matchCount records satisfy the whereClause.

When Became Available

v6.0

Example

if ‘Db.isDefined("CIF","ACN=:ACN") quit

else ...

 

* Variable ACN must be defined prior to the getRecord statement.

* The else statement is incomplete.