Re: PostgreSQL and select nextval

From: Date: Mon, 13 Aug 2007 20:15:46 +0000
Subject: Re: PostgreSQL and select nextval
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-260789@lists.php.net to get a copy of this message
On Sun, August 12, 2007 2:35 am, Alain Roger wrote: > I'm getting an error message when i run the following SQL request : > $sql = "INSERT INTO tmp_importedxls (rec_id, publisher) VALUES (SELECT > nextval('tmp_importedxls_rec_id_seq'),'$pb')"; > > Error in SQL query: ERROR: syntax error at or near "SELECT" LINE 2: > VALUES > (SELECT nextval('tmp_importedxls_rec_id_seq'),' ^ > > I have the feeling that we can not use the select nextval(...) SQL > request > in an INSERT INTO one under PHP. > Is it true? No. PHP doesn't care diddly-squat what is in your query -- It just sends it to PostgreSQL. The query you have written just plain won't work in PostgreSQL, period. Try it in the psql monitor. OT: Almost for sure, you just need to strip out the "VALUES (" bit and the closing paren for it. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So?

« previous php.general (#260789) next »