Lets you use the asterisk (*) and percent (%) pattern matching characters in combination with other symbols to test for the presence of a specified string anywhere inside a string expression. You do not have to use the pattern matching characters if the string you specify matches the data stored in the database exactly. (If the database field is defined as TEXT 10, the string you specify must be exactly ten characters.) Records are included in the record stream if the string specified by match expression is found within the string specified by the value expression. The character * matches any string that maps onto its position. The character % matches any character that maps onto its position. When MATCHING is preceded by the optional qualifier NOT, a record is included in the stream if the pattern string is not found within the target string. MATCHING 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 MATCHING conditional expression and the SORTED clause. These programs create a record stream containing all the records in the EMPLOYEES relation in which the field LAST_NAME begins with the letter "R". Then the programs sort the record stream in ascending numerical order of the employee IDS. These programs print, in numerical order, the employee ID, followed by the last name and first name for all the records in the record stream.
1.1 – C Example
#include <stdio.h> DATABASE PERS = FILENAME "PERSONNEL"; DECLARE_VARIABLE match_string SAME AS EMPLOYEES.LAST_NAME; main() { read_string(match_string,"R*",sizeof(match_string)); READY PERS; START_TRANSACTION READ_ONLY; FOR E IN EMPLOYEES WITH E.LAST_NAME MATCHING match_string SORTED BY E.EMPLOYEE_ID printf ("%s %s %s",E.EMPLOYEE_ID, E.LAST_NAME, E.FIRST_NAME); END_FOR; COMMIT; FINISH; }
1.2 – Pascal Example
program matching (input,output); DATABASE PERS = FILENAME 'PERSONNEL'; var match_string: VARYING [10] OF CHAR; begin match_string := 'R*'; READY PERS; START_TRANSACTION READ_ONLY; FOR E IN EMPLOYEES WITH E.LAST_NAME MATCHING match_string SORTED BY E.EMPLOYEE_ID writeln (E.EMPLOYEE_ID,' ', E.LAST_NAME, E.FIRST_NAME); END_FOR; COMMIT; FINISH; end.
2 – Format
(B)0[mmatching-clause = qqq> value-expr qqqwqq>qqqqqqqwq> [4mMATCHING[m qqq> match-expr qqqq> 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. match-expr A match expression. An expression in quotation marks that is used to match a pattern. Use the double quote character (") in C programs. Use the single quote character (') in Pascal programs. The match expression can include the following special symbols (called wildcards): o * Matches a string of zero or more characters that maps onto its position o % Matches a single character that maps onto its position