On Mon, 24 Jan 2005, William Yu wrote:
> If you absolutely need the display field to be unique and it has to be a
> sequence starting from 1 -- it's simplicity itself. Use the
> serialization errors to your advantage. If you try to insert a record
> and you get a dupe key violation, just increment
Ralph van Etten wrote:
Ok, but then I have the same problem. The "display" field has to be
unique and it needs to use a SELECT MAX in an INSERT query and this gives
the same problem. Only not with the primary key but with possible
duplicate values in the "display" field.
If you absolutely need the
On Sun, 23 Jan 2005, William Yu wrote:
> Ralph van Etten wrote:
> > I agree that a serial would be better.
> >
> > But I think there are situations where a serial isn't convenient
> > Like when you want an primary key which consists of the current
> > year and an sequence number. Like ('05', 1), (
On Sun, Jan 23, 2005 at 10:23:50 +0100,
Ralph van Etten <[EMAIL PROTECTED]> wrote:
> But I think there are situations where a serial isn't convenient
> Like when you want an primary key which consists of the current
> year and an sequence number. Like ('05', 1), ('05', 2), ('05', 3) etc.
> With a
Ralph van Etten wrote:
I agree that a serial would be better.
But I think there are situations where a serial isn't convenient
Like when you want an primary key which consists of the current
year and an sequence number. Like ('05', 1), ('05', 2), ('05', 3) etc.
With a sequence you must write extra
On Sat, 22 Jan 2005, Tino Wildenhain wrote:
> > INSERT INTO test (id, name)
> > SELECT COALESCE(MAX(id)+1, 1), 'name' FROM test
> >
> > Ofcourse this gives problems when two clients are inserting a record at
> > the same time. (duplicate primary keys) But, i can't use a sequence in my
> > applicat
Ralph van Etten wrote:
Hoi,
I searched the archives but couldn't find an answer to this:
I have a table (simplyfied)
CREATE TABLE test (
id INT PRIMARY KEY,
name VARCHAR(250)
);
I insert records with
INSERT INTO test (id, name)
SELECT COALESCE(MAX(id)+1, 1), 'name' FROM test
Ofcourse this giv
Am Samstag, den 22.01.2005, 11:14 +0100 schrieb Ralph van Etten:
> Hoi,
>
> I searched the archives but couldn't find an answer to this:
>
> I have a table (simplyfied)
>
> CREATE TABLE test (
> id INT PRIMARY KEY,
> name VARCHAR(250)
> );
>
> I insert records with
>
> INSERT INTO test (
Hoi,
I searched the archives but couldn't find an answer to this:
I have a table (simplyfied)
CREATE TABLE test (
id INT PRIMARY KEY,
name VARCHAR(250)
);
I insert records with
INSERT INTO test (id, name)
SELECT COALESCE(MAX(id)+1, 1), 'name' FROM test
Ofcourse this gives problems when