>>-IDENTITY_VAL_LOCAL--(--)------------------------------------><
The schema is SYSIBM.
The IDENTITY_VAL_LOCAL function is a non-deterministic function that returns the most recently assigned value for an identity column, where the assignment occurred as a result of a single row INSERT statement using a VALUES clause. The function has no input parameters.
The result is a DECIMAL(31,0), regardless of the actual data type of the identity column to which the result value corresponds.
The value returned is the value assigned to the identity column of the table identified in the most recent single row INSERT statement with a VALUES clause for a table containing an identity column. Note that the INSERT statement must be issued at the same level 1 (that is, the value is available locally at the level it was assigned, until it is replaced by the next assigned value).
The assigned value could be a value supplied by the user (if the identity column is defined as GENERATED BY DEFAULT), or an identity value generated by DB2.
The function returns the null value in the following situations:
The result of the function is not affected by the following statements:
Notes:
Examples:
CREATE TABLE EMPLOYEE (EMPNO INTEGER GENERATED ALWAYS AS IDENTITY, NAME CHAR(30), SALARY DECIMAL(5,2), DEPTNO SMALLINT)
CREATE TABLE T1 (C1 INTEGER GENERATED ALWAYS AS IDENTITY, C2 INTEGER), CREATE TABLE T2 (C1 DECIMAL(15,0) GENERATED BY DEFAULT AS IDENTITY (START WITH 10), C2 INTEGER), INSERT INTO T1 (C2) VALUES (5), INSERT INTO T1 (C2) VALUES (6), SELECT * FROM T1 C1 C2 ----------- ---------- 1 5 2 6 VALUES IDENTITY_VAL_LOCAL() INTO :IVAR
At this point, the IDENTITY_VAL_LOCAL function would return a value of 2 in IVAR, because that was the value most recently assigned by DB2. The following INSERT statement inserts a single row into T2, where column C2 gets a value of 2 from the IDENTITY_VAL_LOCAL function.
INSERT INTO T2 (C2) VALUES (IDENTITY_VAL_LOCAL()), SELECT * FROM T2 WHERE C1 = DECIMAL(IDENTITY_VAL_LOCAL(),15,0) C1 C2 ----------------- ---------- 10. 2
Invoking the IDENTITY_VAL_LOCAL function after this insert results in a value of 10, which is the value generated by DB2 for column C1 of T2.
The following represents a correction to the "OLAP Functions" section under "Expressions" in Chapter 3.
aggregation-function |--column-function--OVER---(--+------------------------------+--> '-| window-partition-clause |--' >----+--------------------------------------------------------------------+> '-| window-order-clause |--+--------------------------------------+--' '-| window-aggregation-group-clause |--' >---------------------------------------------------------------| window-order-clause .-,-------------------------------------------. V .-| asc option |---. | |---ORDER BY-----sort-key-expression--+------------------+--+---| '-| desc option |--' asc option .-NULLS LAST--. |---ASC--+-------------+----------------------------------------| '-NULLS FIRST-' desc option .-NULLS FIRST--. |---DESC--+--------------+--------------------------------------| '-NULLS LAST---' window-aggregation-group-clause |---+-ROWS--+---+-| group-start |---+---------------------------| '-RANGE-' +-| group-between |-+ '-| group-end |-----' group-end |---+-UNBOUNDED FOLLOWING-----------+---------------------------| '-unsigned-constant--FOLLOWING--'
In the window-order-clause description:
In the window-aggregation-group-clause description:
Following is a revised syntax diagram for the Compound Statement:
.-NOT ATOMIC--. >>-+---------+--BEGIN----+-------------+------------------------> '-label:--' '-ATOMIC------' >-----+-----------------------------------------------+---------> | .-----------------------------------------. | | V | | '-----+-| SQL-variable-declaration |-+---;---+--' +-| condition-declaration |----+ '-| return-codes-declaration |-' >-----+--------------------------------------+------------------> | .--------------------------------. | | V | | '----| statement-declaration |--;---+--' >-----+-------------------------------------+-------------------> | .-------------------------------. | | V | | '----DECLARE-CURSOR-statement--;---+--' >-----+------------------------------------+--------------------> | .------------------------------. | | V | | '----| handler-declaration |--;---+--' .-------------------------------. V | >--------SQL-procedure-statement--;---+---END--+--------+------>< '-label--' SQL-variable-declaration .-,--------------------. V | |---DECLARE-------SQL-variable-name---+-------------------------> .-DEFAULT NULL-------. >-----+-data-type----+--------------------+-+-------------------| | '-DEFAULT--constant--' | '-RESULT_SET_LOCATOR--VARYING---------' condition-declaration |---DECLARE--condition-name--CONDITION--FOR---------------------> .-VALUE-. .-SQLSTATE--+-------+---. >----+-----------------------+---string-constant----------------| statement-declaration .-,-----------------. V | |---DECLARE-----statement-name---+---STATEMENT------------------| return-codes-declaration |---DECLARE----+-SQLSTATE--CHAR (5)--+---+--------------------+-| '-SQLCODE--INTEGER----' '-DEFAULT--constant--' handler-declaration |---DECLARE----+-CONTINUE-+---HANDLER--FOR----------------------> +-EXIT-----+ '-UNDO-----' .-,-----------------------------------. V .-VALUE-. | >---------+-SQLSTATE--+-------+--string--+--+-------------------> +-condition-name---------------+ +-SQLEXCEPTION-----------------+ +-SQLWARNING-------------------+ '-NOT FOUND--------------------' >----SQL-procedure-statement------------------------------------|
A statement-declaration declares a list of one or more names that are local to the compound statement. A statement name cannot be the same as another statement name within the same compound statement.
In a Unicode database, the entire repertoire of Unicode characters is uppercased (or lowercased) based on the Unicode properties of these characters. Double-wide versions of ASCII characters, as well as Roman numerals, now case convert correctly.
Change the description of this function to the following:
The schema is SYSFUN. Returns the week of the year of the argument as an integer value in range 1-53. The week starts with Monday and always includes 7 days. Week 1 is the first week of the year to contain a Thursday, which is equivalent to the first week containing January 4. It is therefore possible to have up to 3 days at the beginning of a year appear as the last week of the previous year. Conversely, up to 3 days at the end of a year may appear as the first week of the next year. The argument must be a date, timestamp, or a valid character string representation of a date or timestamp that is neither a CLOB nor a LONG VARCHAR. The result of the function is INTEGER. The result can be null; if the argument is null, the result is the null value. Example: The following list shows examples of the result of WEEK_ISO and DAYOFWEEK_ISO. DATE WEEK_ISO DAYOFWEEK_ISO ---------- ----------- ------------- 1997-12-28 52 7 1997-12-31 1 3 1998-01-01 1 4 1999-01-01 53 5 1999-01-04 1 1 1999-12-31 52 5 2000-01-01 52 6 2000-01-03 1 1
Add the following note to this section in Chapter 3:
The following names, when used in the context of SQL Procedures, are restricted to the characters allowed in an ordinary identifier, even if the names are delimited: - condition-name - label - parameter-name - procedure-name - SQL-variable-name - statement-name
The last paragraph in the description of the fetch-first-clause:
Specification of the fetch-first-clause in a select-statement makes the cursor not deletable (read-only). This clause cannot be specified with the FOR UPDATE clause.
is incorrect and should be removed.
Linux uses libraries called LIBDRDA.SO and LIBSQLNET.SO, not LIBDRDA.A and LIBSQLNET.A as may have been documented previously.