Re: Insert Question
| От | Richard Broersma Jr |
|---|---|
| Тема | Re: Insert Question |
| Дата | |
| Msg-id | 460264.21342.qm@web31804.mail.mud.yahoo.com обсуждение исходный текст |
| Ответ на | Re: Insert Question (<operationsengineer1@yahoo.com>) |
| Ответы |
Re: Insert Question
|
| Список | pgsql-novice |
> create sequence tmp_seq start with 42000005;
>
> update products set document_number =
> nextval('tmp_seq')
> where ocument_number is null;
>
> i had to do it this way because i actually had a few
> entries in the db already. it did work just fine,
> though.
In this case you could:
create sequence temp_seq start with (select max(document_number) from products);
>
> i learned to use...
>
> drop sequence tmp_seq;
>
> in order to reuse the sequence as i was playing around
> with functionality. otherwise, it would return an
> error b/c the sequence already existed.
if you want to use the same sequence over again you could:
select set_val('temp_seq', select max(document_number) from products));
and then do your update.
you will not need to drop your sequence this way.
Regards,
Richard Broersma Jr.
В списке pgsql-novice по дате отправления: