background image
<< NEXT VALUE FOR expression | Expression precedence >>

The DEFAULT keyword

<< NEXT VALUE FOR expression | Expression precedence >>
Derby Reference Manual
95
The next value of a sequence generator is not affected by whether the user commits or
rolls back a transaction which invoked the sequence generator.
A NEXT VALUE expression may not appear in any of these situations:
· CASE expression
· WHERE clause
· ORDER BY clause
· Aggregate expression
· ROW_NUMBER function
· DISTINCT select list
sequenceName
[
schemaName
. ]
SQL92Identifier
If schemaName is not provided, the current schema is the default schema. If a qualified
sequence name is specified, the schema name cannot begin with SYS.
Examples
VALUES (NEXT VALUE FOR order_id);
INSERT INTO re_order_table
SELECT NEXT VALUE FOR order_id, order_date, quantity
FROM orders
WHERE back_order = 1;
UPDATE orders
SET oid = NEXT VALUE FOR order_id
WHERE expired = 1;
VALUES expression
The VALUES expression allows construction of a row or a table from other values. A
VALUES expression can be used in all the places where a query can, and thus can be
used in any of the following ways:
· As a statement that returns a ResultSet
· Within expressions and statements wherever subqueries are permitted
· As the source of values for an INSERT statement (in an INSERT statement, you
normally use a VALUES expression when you do not use a
SelectExpression
)
Syntax
{
VALUES ( Value {, Value }* )
[ , ( Value {, Value }* ) ]* |
VALUES Value [ , Value ]*
} [
ORDER BY clause
]
[
result offset clause
]
[
fetch first clause
]
where Value is defined as
Expression | DEFAULT
The first form constructs multi-column rows. The second form constructs single-column
rows, each expression being the value of the column of the row.
The DEFAULT keyword is allowed only if the VALUES expression is in an INSERT
statement. Specifying DEFAULT for a column inserts the column's default value into the
column. Another way to insert the default value into the column is to omit the column from
the column list and only insert values into other columns in the table.