pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Shavonne Marietta Wijesinghe <shavonne.marietta@studioform.it>
To: pgsql-sql@postgresql.org
Subject: Re: Serial
Date: Tue, 3 Apr 2007 11:55:10 +0200
Message-ID: <00b101c775d6$2d313840$1102a8c0@dream> (raw)
References: <008301c775d1$4b224420$1102a8c0@dream>
	<20070403093222.GB30108@a-kretschmer.de>

thanks. I read the page you gave.

CREATE SEQUENCE seq_mytable_n_gen;

CREATE TABLE mytable
(
  n_gen int nextval('seq_mytable_n_gen'),
  mycolumn1 int,
  mycolumn2 int
);


i tried creating it like that. The sequence was created without any error. 
But for the create table i get

ERROR:  syntax error at or near "nextval" at character 38

What should i do?


Shavonne Wijesinghe

----- Original Message ----- 
From: "A. Kretschmer" <andreas.kretschmer@schollglas.com>
To: <pgsql-sql@postgresql.org>
Sent: Tuesday, April 03, 2007 11:32 AM
Subject: Re: [SQL] Serial


> am  Tue, dem 03.04.2007, um 11:20:16 +0200 mailte Shavonne Marietta 
> Wijesinghe folgendes:
>> The problem is when i INSERT a new record. It takes the value n_gen = 6 
>> but i
>> need it to take the value 5. It keeps a record of the delete records.
>>
>> Is there anyway in PostgreSQL i can change it? or another progressive 
>> that i
>> can use for n_gen ??
>
> Yes, setval().
> http://www.postgresql.org/docs/8.1/interactive/functions-sequence.html
>
>
> Andreas
> -- 
> Andreas Kretschmer
> Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
> GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: You can help support the PostgreSQL project by donating at
>
>                http://www.postgresql.org/about/donate 




view thread (9+ messages)  latest in thread

Message-ID: <00b101c775d6$2d313840$1102a8c0@dream>
Permalink:  ../00b101c775d6$2d313840$1102a8c0@dream/
Also on:    postgresql.org/message-id/00b101c775d6$2d313840$1102a8c0@dream

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: shavonne.marietta@studioform.it
  Subject: Re: Serial
  In-Reply-To: <00b101c775d6$2d313840$1102a8c0@dream>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox