From: | Patrice Hédé <patrice(at)idf(dot)net> |
---|---|
To: | Jerome ALET <alet(at)unice(dot)fr> |
Cc: | pgsql-sql(at)postgreSQL(dot)org, tony(at)cys(dot)de |
Subject: | Re: [SQL] nextval |
Date: | 1998-05-28 09:48:08 |
Message-ID: | Pine.LNX.3.96.980528114405.29416A-100000@paris.ivo.fr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Thu, 28 May 1998, Jerome ALET wrote:
> I was wrong because I had forgotten the '' but it still doesn't work
> correctly:
> First I had to remove PRIMARY KEY and NOT NULL because when I did the
> INSERT it complained about inserting a null value. This is because the
> NOT NULL check is automatically done before the RULE is executed. Is it
> a bug or a feature ? Maybe we should be able to choose the order but
> this should not exist in ANSI SQL...
> Second, look at the results of a similar RULE:
>
> CREATE TABLE auteurs (numero_auteur INT4, nom_auteur TEXT, prenom_auteur
> TEXT, email_auteur TEXT);
>
> CREATE SEQUENCE seq_auteurs INCREMENT 1 MINVALUE 1 START 1;
> CREATE
Maybe you should consider doing it with a default value as :
CREATE TABLE auteurs (numero_auteur int4 default nextval('seq_auteurs'),
nom_auteur text,
prenom_auteur text,
email_auteur text
);
and then, you don't need to create a rule.
then insert like this :
INSERT INTO auteurs( nom_auteur ) VALUES ( 'Jerome' );
should give you what you want, if what you really need is a unique ID.
Hope it helps :)
Patrice
--
Patrice HÉDÉ --------------------------------- patrice(at)idf(dot)net -----
... Looking for a job in Iceland or in Norway !
Ingénieur informaticien - Computer engineer - Tölvufræðingur
----- http://www.idf.net/patrice/ ----------------------------------
From | Date | Subject | |
---|---|---|---|
Next Message | Jerome ALET | 1998-05-28 10:01:07 | Re: [SQL] nextval |
Previous Message | Jerome ALET | 1998-05-28 08:39:44 | Re: [SQL] nextval |