%KeyEqual meta-SQL element
Syntax
%KeyEqual(recname [ correlation_id])
Description
The %KeyEqual meta-SQL construct expands into a conditional phrase suitable for use in a Where clause.
The conditional phrase consists of a conjunction (AND) of [correlation_id.]keyfieldname = 'keyfieldvalue' phrases for each key field of the given record.
No auto-update processing is done, but other input processing is applied to the values, according to the following:
-
If the field is a Date, a Time, or a DateTime data type, its value is automatically wrapped in %Datein, %TimeIn, or %DateTimeIn, respectively.
-
If a value is a string, its value is automatically wrapped in quotation marks.
-
If a value is NULL, the "=value" part is replaced with "IS NULL".
Note:
This meta-SQL can only be used in PeopleCode programs, not in Application Engine SQL actions. Also, this meta-SQL is not implemented for COBOL.
Parameters
| Parameter | Description |
|---|---|
|
recname |
Specify the name of the record to use for inserting. This can be a bind variable, a record object, or a record name in the form recname. You cannot specify RECORD. recname, a record name in quotation marks, or a table name. |
|
correlation_id |
Identify the single-letter correlation ID to relate the record specified by recname and its fields. |
Example
Suppose that the record &REC has three keys: FNUM, FDATE, and FSMART. Here is a code example:
Local record &REC;
&REC = CreateRecord(RECORD.MYRECORD);
&REC.FNUM.Value = 27;
&REC.FDATE.Value = %Date;
SQLExec("Delete from MYRECORD A where %KeyEqual(:1 A)", &REC);
This example expands to:
"Delete from TABLE A
where A.FNUM = 27
AND A.FDATE = %Date('1989-11-27')
AND A.FSMART IS NULL"