Download Informix Guide to SQL: Syntax

Transcript
Condition
You can also use a single-character host variable as an escape character. The
following statement shows the use of a host variable as an escape character:
EXEC SQL BEGIN DECLARE SECTION;
char escp='z';
char fname[20];
EXEC SQL END DECLARE SECTION;
EXEC SQL select fname from customer
into :fname
where company like '%z_%' escape :escp;
ESCAPE with MATCHES
The ESCAPE clause lets you include a question mark (?), an asterisk (*), and a
left or right bracket ([]) in the quoted string and avoid having them be interpreted as wildcards. If you choose to use z as the escape character, the
characters z? in a string stand for the question mark (?). Similarly, the
characters z* stand for the asterisk (*). Finally, the characters zz in the string
stand for the single character z.
The following example retrieves rows from the customer table in which the
value of the company column includes the question mark (?):
SELECT * FROM customer
WHERE company MATCHES '*z?*' ESCAPE 'z'
Condition with a Subquery
Condition
with
Subquery
IN
Subquery
p. 1-653
EXISTS
Subquery
p. 1-654
ALL/ANY/SOME
Subquery
p. 1-655
1-652
Informix Guide to SQL: Syntax