From: | Stefan Schwarzer <stefan(dot)schwarzer(at)grid(dot)unep(dot)ch> |
---|---|
To: | Julius Tuskenis <julius(dot)tuskenis(at)gmail(dot)com>, "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: How to INSERT empty line into SEQUENTIAL table from PHP |
Date: | 2008-06-16 07:56:28 |
Message-ID: | 09BF9E4A-6CCC-4D60-81A9-75CED5D1216E@grid.unep.ch |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
It doesn't work like this:
INSERT INTO page_input (id, page, text_en, text_fr, text_es, text_ar)
VALUES (NULL, '', '', '', '', '')
--> ERROR: null value in column "id" violates not-null constraint
nor like this:
INSERT INTO page_input (page, text_en, text_fr, text_es, text_ar)
VALUES ('', '', '', '', '')
--> ERROR: duplicate key value violates unique constraint "id_unique"
nor like this:
INSERT INTO page_input (id, page, text_en, text_fr, text_es, text_ar)
VALUES (nextval('page_input_id_seq'::regclass), '', '', '', '', '')
--> ERROR: duplicate key value violates unique constraint "id_unique"
On Jun 16, 2008, at 8:54 AM, Julius Tuskenis wrote:
> Hi, Stefan.
>
> your second example should work for you.
> INSERT INTO table_xx (field2, field3, field4) VALUES ('', '', '');
> (keeping in mind, that your ID column is of type serial or has
> DEFAULT NEXTVAL('some_sequence') ).
> You can also insert values yourself:
> INSERT INTO table_xx (ID, field2, field3, field4) VALUES
> (NEXTVAL('some_sequence'), '', '', '');
>
> Julius Tuskenis
>
>
>
> Stefan Schwarzer rašė:
>> Hi,
>>
>> rahter dump question, I guess....
>>
>> But I have a table with a sequential index field, into which I
>> would like to add from time to time another line (via webbrowser),
>> which in turn, stays first empty, before it's being filled in later
>> (via webbrowser).
>>
>> Because the ID field is sequential and indexed, I can't use
>>
>> INSERT INTO table_xx (ID, field2, field3, field4) VALUES ('',
>> '', '', '');
>>
>> neither (skipping ID because it should be filled in automatically):
>>
>> INSERT INTO table_xx (field2, field3, field4) VALUES ('', '', '');
>>
>> How am I supposed to do it?
>>
>> Thanks for any hints,
>>
>> Stef
>>
>>
From | Date | Subject | |
---|---|---|---|
Next Message | Julius Tuskenis | 2008-06-16 08:03:31 | Re: How to INSERT empty line into SEQUENTIAL table from PHP |
Previous Message | Julius Tuskenis | 2008-06-16 06:54:48 | Re: How to INSERT empty line into SEQUENTIAL table from PHP |