Re: nextval() clarification
| От | Ennio-Sr |
|---|---|
| Тема | Re: nextval() clarification |
| Дата | |
| Msg-id | 20040913195410.GA10247@deby.ei.hnet обсуждение |
| Ответ на | nextval() clarification (Greg Donald <destiney@gmail.com>) |
| Ответы |
Re: nextval() clarification
|
| Список | pgsql-novice |
* Greg Donald <destiney@gmail.com> [130904, 13:59]:
> Long time MySQL user, six weeks into Postgres here.
>
> I'm converting a PHP script that uses MySQL to use Postgres instead.
> To substitue the missing MySQL functionaility with mysql_insert_id()
> and auto_increment I am using code like this:
>
> $sql = "SELECT nextval('companies_company_id_seq'::text)";
>
> And then I do my insert with that value.
> [ cut ]
I think you should put <nextval(....)> directly into the INSERT
instruction, so that it advances only once per added record.
Have a look at Documentation PostgreSQL 7.4, Ch 9.11, table 9.34.
HTH
Regards, Ennio
--
[Perche' usare Win$ozz (dico io) se ..."anche uno sciocco sa farlo. \\?//
Fa' qualche cosa di cui non sei capace!" (diceva Henry Miller) ] (°|°)
[Why to use Win$ozz (I say) if ... "even a fool can do that. )=(
Do something you aren't good at!" (used to say Henry Miller) ]
В списке pgsql-novice по дате отправления: