From: | Suresh Borse <s(dot)borse(at)direction(dot)biz> |
---|---|
To: | Marc Fromm <Marc(dot)Fromm(at)wwu(dot)edu> |
Cc: | "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org> |
Subject: | Re: primary key and insert |
Date: | 2008-12-12 05:38:41 |
Message-ID: | 1229060321.2256.1.camel@dss-052.dsslp.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
Create a sequence and use the sequence in your insert statement.
On Thu, 2008-12-11 at 15:27 -0800, Marc Fromm wrote:
> I created this table:
> Column | Type | Modifiers
> ------------+------------------------+------------------------
> first_name | character varying(20) |
> last_name | character varying(30) |
> w_number | character varying(9) |
> alert | character varying(200) |
> post_date | date |
> id | integer | not null
> Indexes:
> "alert_list_pkey" PRIMARY KEY, btree (id)
>
> I get this error when I run the insert a listed below. The insert does
> not have an entry for the primary key "id" since I thought it updates
> automatically:
> Warning: pg_query() [function.pg-query]: Query failed: ERROR: null
> value in column "id" violates not-null constraint
>
> $sql = "INSERT INTO alert_list (
> w_number,
> first_name,
> last_name,
> alert,
> post_date
> )
> VALUES (
> '$txtStudentNumber',
> '$txtStudentFirstName',
> '$txtStudentLastName',
> '$txtStudentAlert',
> 'now()'
> )";
>
> How do I do an insert on this table and have the primary key "id"
> update with the record?
>
> thanks
>
> Marc
Thanks & Regards,
Suresh Borse
(DBA)
_________________________________________________________________________________________
DIRECTION SOFTWARE SOLUTIONS
5, Brady Gladys Plaza, 1/447, Senapati Bapat Marg, Lower Parel, Mumbai -
400 013
Tel. : 91 22 66615000 (Ext: 350) Fax : 91 22
24911046
Cell : 91 9422 239338 Site :
www.direction.biz
_________________________________________________________________________________________
From | Date | Subject | |
---|---|---|---|
Next Message | Albe Laurenz | 2008-12-12 07:12:08 | Re: [GENERAL] Tool to converter plsql in pgplsql |
Previous Message | johnf | 2008-12-12 02:09:47 | Re: primary key and insert |