%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.
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"