DB2 Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDB2 Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old February 22nd, 2005, 10:04 AM
oana12 oana12 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 16 oana12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 39 m 27 sec
Reputation Power: 0
Identity_val_local()

Hi,
I have a strange problem with IDENTITY_VAL_LOCAL().I am using DB2 UDB Express 8.2 on Windows 2003. Sometimes when I want to insert a values in a table give me the error 'You are attempting to add an entry that already exists. ' - seem that IDENTITY is not incremented by 1.

Which can be the cause ? the column is declared GENERATED BY DEFAULT AS IDENTITY( START WITH 1, INCREMENT BY 1, NO CYCLE,MINVALUE 1,MAXVALUE 2147483647, CACHE 20 )

Thanks

Reply With Quote
  #2  
Old February 22nd, 2005, 03:18 PM
fractalvibes fractalvibes is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2003
Location: Waco, Texas
Posts: 632 fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Week 14 h 11 m 13 sec
Reputation Power: 22
Not sure, but here is example DDL from one of my tables:

(ITEM_NBR BIGINT NOT NULL GENERATED BY DEFAULT
AS IDENTITY (START WITH 0, INCREMENT BY 1, NO CACHE, MINVALUE 0, MAXVALUE 9223372036854775807, NO CYCLE, NO ORDER),

You aren't trying to actually supply a value when you insert, are you? DB2 should automatically provide that for you.

identity_val_local() is used to get the ID of the row you JUST inserted.

fv
__________________
...because that is the way we have always done it. We've been doing it like that for 80 Years! (How do we change that mindset?)

Reply With Quote
  #3  
Old February 23rd, 2005, 12:54 PM
oana12 oana12 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 16 oana12 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 39 m 27 sec
Reputation Power: 0
Identity_val_local()

I have the same syntax like you. Can be the problem that I am importing (moving) the database from another. I heard that in this situation it is possible that IDENTITY_VAL_LOCAL() to lose the order and is possible to give you a value which exist. Is this true?

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDB2 Development > Identity_val_local()


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway