470,636 Members | 1,634 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,636 developers. It's quick & easy.

DB2 Performance issue

HI Everybody ,

This is the DB2 performance issue I was referring to .
We have requirement where we need to insert some values to the DB2
table and
get back its ID. Its possible by using an insert query , followed by
select
ID query. (Using IDENTITY_LOCAL_VAR)
However what we are looking for is (ofcourse, an ideal case) a single
query
which performs insert and returns sequence generated. (To adress some
performance bottlenecks)
My experience with this kind of thing is with Oracle and in those
cases, the
new sequence/identity is returned as part of the result object itself
(i.e.
you don't need to query the database again).
If there is any similar construct in DB2, it would be of greater help.

Thanks in Advance

Jan 4 '06 #1
1 1434
Raja Shekar wrote:
HI Everybody ,

This is the DB2 performance issue I was referring to .
We have requirement where we need to insert some values to the DB2
table and
get back its ID. Its possible by using an insert query , followed by
select
ID query. (Using IDENTITY_LOCAL_VAR)
However what we are looking for is (ofcourse, an ideal case) a single
query
which performs insert and returns sequence generated. (To adress some
performance bottlenecks)
My experience with this kind of thing is with Oracle and in those
cases, the
new sequence/identity is returned as part of the result object itself
(i.e.
you don't need to query the database again).
If there is any similar construct in DB2, it would be of greater help.

Thanks in Advance

CREATE TABLE T(id INT NOT NULL GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
c1 INT);
SET id = (SELECT id FROM NEW TABLE(INSERT INTO T(c1) VALUES(5);

Check out:
http://www-128.ibm.com/developerwork...dm-0411rielau/

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
DB2 UDB for Linux, Unix, Windows
IBM Toronto Lab
Jan 4 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by **ham | last post: by
115 posts views Thread by Mark Shelor | last post: by
13 posts views Thread by bjarne | last post: by
7 posts views Thread by James | last post: by
17 posts views Thread by 57R4N63R | last post: by
5 posts views Thread by Varangian | last post: by
1 post views Thread by Korara | last post: by
???
reply views Thread by Stoney L | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.