Re: problem inserting with sequence

From: Gnanavel S <s(dot)gnanavel(at)gmail(dot)com>
To: germ germ <super_code_monkey(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: problem inserting with sequence
Date: 2005-07-28 12:46:44
Message-ID: eec3b03c050728054612315a2c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 7/28/05, germ germ <super_code_monkey(at)yahoo(dot)com> wrote:
>
> I have been trying to figure out why I can't insert
> into a table and I think it has something to do with
> the sequnce.
>
> I am able to use able to properly insert into the
> table using the the shell, but I am not able to insert
> using a php script:
>
> INSERT INTO requests (time_stamp, req_num,
> recommended_by) VALUES (now(),
> nextval('requests_req_num_seq'), 'foo');
>
> Here is the schema I'm using:
> DROP SEQUENCE requests_req_num_seq;
> DROP TABLE requests;
>
> CREATE SEQUENCE requests_req_num_seq INCREMENT BY 1
> START WITH 1000;
>
> CREATE TABLE requests (
> time_stamp timestamp PRIMARY KEY DEFAULT 'now',
> req_num integer DEFAULT
> nextval('acq_requests_req_num_seq') NOT NULL,

where is this sequence 'acq_requests_req_num_seq' created. You have created
only 'requests_req_num_seq'

recommended_by varchar(35) NOT NULL
> );
> GRANT ALL ON requests TO wwwrun, postgres;
>
> If I reconfigure the schema by removing the sequence
> from the table, I am able to insert into the table
> using both the shell and php script:
> DROP SEQUENCE requests_req_num_seq;
> DROP TABLE requests;
>
> CREATE SEQUENCE requests_req_num_seq INCREMENT BY 1
> START WITH 1000;
>
> CREATE TABLE requests (
> time_stamp timestamp PRIMARY KEY DEFAULT 'now',
> recommended_by varchar(35) NOT NULL
> );
>
> INSERT INTO requests (time_stamp, recommended_by)
> VALUES (now(), 'foo');
>
> I'm a little stumped on this one. I'm running
> PostgreSQL 7.4.8 on i686-pc-linux-gnu, compiled by GCC
> gcc (GCC) 3.3.3 (SuSE Linux).
>
> Thanks in advance for any help or advice.
>
>
>
> __________________________________
> Yahoo! Mail for Mobile
> Take Yahoo! Mail with you! Check email on your mobile phone.
> http://mobile.yahoo.com/learn/mail
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>

--
with regards,
S.Gnanavel
Satyam Computer Services Ltd.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2005-07-28 13:01:21 Re: problem inserting with sequence
Previous Message Dorine Periolat 2005-07-28 12:41:59 Trigger ad mutli database