Re: nextval() clarification - Mailing list pgsql-novice

From Ennio-Sr
Subject Re: nextval() clarification
Date
Msg-id 20040913195410.GA10247@deby.ei.hnet
Whole thread Raw
In response to nextval() clarification  (Greg Donald <destiney@gmail.com>)
Responses Re: nextval() clarification
List 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 by date:

Previous
From: Aarni Ruuhimäki
Date:
Subject: Re: nextval() clarification
Next
From: Aarni Ruuhimäki
Date:
Subject: Re: nextval() clarification