Download HyperSQL User Guide

Transcript
Data Access and Change
((1, NULL, ...) < (2, NULL, ...)) IS TRUE
((2, NULL, ...) < (1, NULL, ...)) IS FALSE
BETWEEN
between predicate
<between predicate> ::= <row value predicand> <between predicate part 2>
<between predicate part 2> ::= [ NOT ] BETWEEN [ ASYMMETRIC | SYMMETRIC ] <row
value predicand> AND <row value predicand>
Specify a range comparison. The default is ASYMMETRIC. The expression X BETWEEN Y AND Z is equivalent to
(X >= Y AND X <= Z). Therefore if Y > Z, the BETWEEN expression is never true. The expression X BETWEEN
SYMMETRIC Y AND Z is equivalent to (X >= Y AND X <= Z) OR (X >= Z AND X <= Y). The
expression Z NOT BETWEEN ... is equivalent to NOT (Z BETWEEN ...). If any of the three <row value
predicand> evaluates to NULL, the result is UNKNOWN.
IN
in predicate
<in predicate> ::= <row value predicand> [ NOT ] IN <in predicate value>
<in predicate value> ::= <table subquery> | <left paren> <in value list> <right
paren>
| <left paren> UNNEST <left paren> <array value expression> <right paren> <right
paren>
<in value list> ::= <row value expression> [ { <comma> <row value expression> }... ]
Specify a quantified comparison. The expression X NOT IN Y is equivalent to NOT (X IN Y). The ( <in
value list> ) is converted into a table with one or more rows. The expression X IN Y is equivalent to X =
ANY Y, which is a <quantified comparison predicate>.
If the <table subquery> returns no rows, the result is FALSE. Otherwise the <row value predicand> is
compared one by one with each row of the <table subquery>.
If the comparison is TRUE for at least one row, the result is TRUE. If the comparison is FALSE for all rows, the result
is FALSE. Otherwise the result is UNKNOWN.
HyperSQL supports an extension to the SQL Standard to allow an array to be used in the <in predicate value>. This is
intended to be used with prepared statements where a variable length array of values can be used as the parameter value
for each call. The example below shows how this is used in SQL. The JDBC code must create a new java.sql.Array
object that contains the values and set the paraemter with this array.
SELECT * FROM customer WHERE firstname IN ( UNNEST(?) )
Connection conn;
PreparedStatement ps;
// conn and ps are instantiated here
Array arr = conn.createArrayOf("INTEGER", new Integer[] {1, 2, 3});
ps.setArray(1, arr);
ResultSet rs = ps.executeQuery();
LIKE
108