AW: Serial field and insert, maybe a very stupid question
Posted in 2008
As I said, a long time since I tried this last time, and still I remembered getting punished for it.
So I better add a unique index now, just to be save.
Thank you very much.
regards,
Joerg Volz
________________________________
Von: Colin Dawson [mailto:cjd_1955@hotmail.com]
Gesendet: Mi 06.08.2008 14:32
An: Jörg Volz; Informix list
Betreff: RE: Serial field and insert, maybe a very stupid question
An insert into a table with a serial column will have the highest serial value+1, that is all a serial column does, to ensure uniqueness you must an a unique index as well. A lot of people miss this part of it assuming a serial column also enforces unique values
Regards
Colin
There are 10 types of people in the world, those that understand binary and those that don't
________________________________
Subject: Serial field and insert, maybe a very stupid question
Date: Wed, 6 Aug 2008 14:27:14 +0200
From: Joerg@it-volz.de
To: informix-list@iiug.org
Hy,
I have two identical tables on two different IDS 10 Servers.
Both tables look exactly the same, structure like that:
create table tblSomething{
idxodbc serial,
Textfield char(20)
}
Both tables have the same data, 12 rows with idbxodbc from 1 to 12 and some text in each row.
1 SomeText
2 Moretext
...
12 lasttext
Now I did an
INSERT INTO tbSomething -- working on Server1
SELECT *
FROM database@Server2:tblSomething
I expected to get a hit on my finger for writing exactly the same Values in a serial defined field, but the Insert just ran and I ended up with two rows with idxodbc=1, two rows with idxodbc=2 and so forth...
1 SomeText
1 SomeText
2 Moretext
2 Moretext
...
12 lasttext
12 lasttext
Is this normal behaviour? I am very surprised, but it has been a long time since I tried to mess up with serial defined fields. (once with Online 4.x when I started Informix)
regards,
Joerg Volz
IT Handel und Beratung Jörg Volz
Bernhard-Früh-Str. 7
77855 Achern
GERMANY
Tel: 07841-681651
Fax: 07841-681654
Mobil: 0170-2989757
Ust-ID: DE201383541
http://www.it-volz.de <http://www.it-volz.de/>
________________________________
Get Hotmail on your mobile from Vodafone Try it Now! <http://clk.atdmt.com/UKM/go/107571435/direct/01/>