Unix Technical Forum

DB2 Performance issue

This is a discussion on DB2 Performance issue within the DB2 forums, part of the Database Server Software category; --> HI Everybody , This is the DB2 performance issue I was referring to . We have requirement where we ...


Go Back   Unix Technical Forum > Database Server Software > DB2

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 06:43 AM
Raja Shekar
 
Posts: n/a
Default 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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 06:43 AM
Serge Rielau
 
Posts: n/a
Default Re: DB2 Performance issue

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:37 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com