Re: Insert Question - Mailing list pgsql-novice

From Richard Broersma Jr
Subject Re: Insert Question
Date
Msg-id 12337.980.qm@web31809.mail.mud.yahoo.com
Whole thread Raw
In response to Insert Question  (<operationsengineer1@yahoo.com>)
Responses Re: Insert Question  (<operationsengineer1@yahoo.com>)
List pgsql-novice
> hhi all,
>
> long time no askie question, but here goes...
>
> i want to insert sequential document numbers into a
> products table
>
> my current setup is like so:
>
> product_number document_number
> 1001
> 1002
> 1006
> 1005
>
> i want an insert statement that will yield the
> following:
>
> product_number document_number
> 1001           42000001
> 1002           42000002
> 1006           42000003
> 1005           42000004
>
> relative order means nothing, but i do want sequential
> document numbers.
>
> how can i go about getting this done as efficiently as
> possible?
>
> as always, tia.

create sequence tmp_seq start with 42000000;

update products set document_number = nextval('tmp_seq');

Would this do what you want?

Regards,

Richard Broersma Jr.

pgsql-novice by date:

Previous
From: "Davis, Sean \(NIH/NCI\) [E]"
Date:
Subject: Re: Insert Question
Next
From: "Davis, Sean \(NIH/NCI\) [E]"
Date:
Subject: Re: Number of fields in split()