Search Postgresql Archives

Re: problem inserting with sequence

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



germ germ 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,
	recommended_by		varchar(35)	NOT NULL
);			
GRANT ALL ON requests TO wwwrun, postgres;

Check you server logs and it should tell you why. Actually, check the error code in your PHP and it should tell you why.

My immediate guess - you haven't granted permission to the sequence for user "wwwrun".

--
  Richard Huxton
  Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux