Tests for the presence of a specified string anywhere inside a string expression. A conditional expression that includes a CONTAINING clause is true if the string specified by the second (pattern) string expression is found within the string specified by the first (target) string expression. If either of the string expressions in a CONTAINING conditional expression is missing, the result is missing. If you precede the CONTAINING clause with the optional NOT qualifier, the condition is true if there are no records containing the specified string. CONTAINING is not case sensitive; it considers uppercase and lowercase forms of the same character to be a match.
1 – Examples
The following programs demonstrate the use of the CONTAINING conditional expression. These programs create a record stream containing all the records in the EMPLOYEES relation in which the LAST_NAME field contains the string "IACO" (in upper or lower case letters). These programs print the employee ID and last name from all the records contained in the record stream.
1.1 – C Example
#include <stdio.h> DATABASE PERS = FILENAME "PERSONNEL"; main() { READY PERS; START_TRANSACTION READ_ONLY; FOR E IN EMPLOYEES WITH E.LAST_NAME CONTAINING "IACO" printf ("%s %s\n", E.EMPLOYEE_ID, E.LAST_NAME); END_FOR; COMMIT; FINISH; }
1.2 – Pascal Example
program containing (input,output); DATABASE PERS = FILENAME 'PERSONNEL'; begin READY PERS; START_TRANSACTION READ_ONLY; FOR E IN EMPLOYEES WITH E.LAST_NAME CONTAINING 'IACO' writeln (E.EMPLOYEE_ID, ' ', E.LAST_NAME); END_FOR; COMMIT; FINISH; end.
2 – Format
(B)0[mcontaining-clause = qqq> value-expr qqqwqq>qqqqqqqwqq> [4mCONTAINING[m qqq> value-expr qqq> mqq> [4mNOT[m qqj
2.1 – Format arguments
value-expr A value expression. A symbol or a string of symbols used to calculate a value. When you use a value expression in a statement, Oracle Rdb calculates the value associated with the expression and uses that value when executing the statement.