On Fri, 15 Aug 2003, cristi wrote:

> What is wrong here?
> 
> insert into table_name (field_name) values (select
> setval('sequence_name')-1) as currval);

Your probably want this instead:

  insert into table_name (field_name) values (nextval('sequence_name'));

The reason why your insert fail above is that setval() should have more 
parameters, but even if it had worked it does not make sense to call 
setval() there. See

  http://www.postgresql.org/docs/7.3/static/functions-sequence.html

Also, it's easier to use a serial column:

  http://www.postgresql.org/docs/7.3/static/datatype.html#DATATYPE-SERIAL

then you can do

  insert into table_name (field_name) values (DEFAULT);

-- 
/Dennis


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Reply via email to