Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Novice > Re: Automatical...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 4 Topic 3053 of 3255
Post > Topic >>

Re: Automatically update sequence

by sdavis2@[EMAIL PROTECTED] ("Sean Davis") Mar 28, 2008 at 12:28 PM

On Fri, Mar 28, 2008 at 11:54 AM, Ognjen Blagojevic <ognjen@[EMAIL PROTECTED]
>
wrote:
> Hi all,
>
>  Is it possible to automatically update the sequence after the literal
>  value was used in INSERT statement?
>
>  For instance,
>
>  CREATE SEQUENCE test_table_id;    -- test_table_id = 1
>  CREATE TABLE test_table (
>     id INTEGER NOT NULL DEFAULT nextval('test_table_id') CHECK (id >=
0),
>     column1 VARCHAR(255),
>     PRIMARY KEY (id)
>  )
>
>  INSERT INTO test_table (id, column1) VALUES (1000, 'something');
>
>  Here, I used literal value for ID (1000), and I want my sequence to be
>  updated to 1000 automatically (i.e. without calling setval).
>
>  I'm trying to achieve something similar to MySQL's auto_increment
feature.

You'll probably want to look at currval and nextval.

Sean

-- 
Sent via pgsql-novice mailing list (pgsql-novice@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice
 




 4 Posts in Topic:
Automatically update sequence
ognjen@[EMAIL PROTECTED]   2008-03-28 16:54:11 
Re: Automatically update sequence
sdavis2@[EMAIL PROTECTED]  2008-03-28 12:28:58 
Re: Automatically update sequence
ahodgson@[EMAIL PROTECTED  2008-03-28 09:35:56 
Re: Automatically update sequence
ognjen@[EMAIL PROTECTED]   2008-03-28 17:39:43 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Oct 11 20:18:11 CDT 2008.