Re: primary key and insert

Поиск
Список
Период
Сортировка
От Suresh Borse
Тема Re: primary key and insert
Дата
Msg-id 1229060321.2256.1.camel@dss-052.dsslp.com
обсуждение исходный текст
Ответ на primary key and insert  (Marc Fromm <Marc.Fromm@wwu.edu>)
Список 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
_________________________________________________________________________________________

В списке pgsql-admin по дате отправления:

Предыдущее
От: johnf
Дата:
Сообщение: Re: primary key and insert
Следующее
От: "Albe Laurenz"
Дата:
Сообщение: Re: [GENERAL] Tool to converter plsql in pgplsql