db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mamta A. Satoor (JIRA)" <derby-...@db.apache.org>
Subject [jira] Commented: (DERBY-287) Return value of IDENTITY_VAL_LOCAL for different connections is not related.
Date Sun, 15 May 2005 02:24:04 GMT
     [ http://issues.apache.org/jira/browse/DERBY-287?page=comments#action_65418 ]
     
Mamta A. Satoor commented on DERBY-287:
---------------------------------------

While we are working on fixing IDENTITY_VAL_LOCAL documentation, let's add the relevant information
for triggers as well. Here is the info about it but can someone please re-word this properly
for documentation? 

If a table with an identity column has an insert trigger defined which inserts into another
table with identity column, then IDENTITY_VAL_LOCAL() function will return the generated value
for the statement table and not for the table modified by the trigger. 
eg
$ java -Dij.exceptionTrace=true org.apache.derby.tools.ij
ij version 10.1
ij> connect 'jdbc:derby:c:/dellater/db1';
ij> create table t1 (c11 int generated always as identity (start with 101, increment by
3), c12 int); 
0 rows inserted/updated/deleted
ij> create table t2 (c21 int generated always as identity (start with 201, increment by
5), c22 int);
0 rows inserted/updated/deleted
ij> create trigger t1tr1 after insert on t1 for each row mode db2sql insert into t2 (c22)
values (1); 
0 rows inserted/updated/deleted
ij> values IDENTITY_VAL_LOCAL();
1
-------------------------------
NULL

1 row selected
ij> insert into t1 (c12) values (1);
1 row inserted/updated/deleted
ij> values IDENTITY_VAL_LOCAL();
1
-------------------------------
101

1 row selected
ij> select * from t1;
C11        |C12
-----------------------
101        |1

1 row selected
ij> select * from t2;
C21        |C22
-----------------------
201        |1

1 row selected
ij>





> Return value of IDENTITY_VAL_LOCAL for different connections is not related.
> ----------------------------------------------------------------------------
>
>          Key: DERBY-287
>          URL: http://issues.apache.org/jira/browse/DERBY-287
>      Project: Derby
>         Type: Bug
>     Reporter: Mamta A. Satoor

>
> The current IDENTITY_VAL_LOCAL documentation (http://incubator.apache.org/derby/docs/ref/ref-single.html#rrefidentityvallocal)
is unclear if the IDENTITY_VAL_LOCAL function returns the most recently assigned value for
an identity column, for a connection/transaction/database and it needs to be fixed to say
that it is for a connection.
> The first line in the current doc is "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. " It should read
as "The IDENTITY_VAL_LOCAL function is a non-deterministic function that, for a connection,
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."
> There is another line on the same page which reads "The value returned by the IDENTITY_VAL_LOCAL
function is the value assigned to the identity column of the table identified in the most
recent single row INSERT statement."  This needs to be slightly modified to say "The value
returned by the IDENTITY_VAL_LOCAL function, for a connection, is the value assigned to the
identity column of the table identified in the most recent single row INSERT statement."

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message