Re: OID Usage - Mailing list pgsql-general

From Bo Lorentsen
Subject Re: OID Usage
Date
Msg-id 41E7A17A.6080803@netgroup.dk
Whole thread Raw
In response to Re: OID Usage  (Christian Kratzer <ck-lists@cksoft.de>)
Responses Re: OID Usage  (Alvaro Herrera <alvherre@dcc.uchile.cl>)
List pgsql-general
Christian Kratzer wrote:

> why should your application not want to know about the metadata of it's
> own tables ? That sounds quite strange when you think about it.

Well, the ideer is to be compatible with mysql at the same level in the
code. This works nicely, as I have descriped, but I am concerned if
there is any strains attached to this method.

It is all found in the : http://lue.dk/prj/dbc/index.html

> If you name your sequences in a generic way you can alway construct
> the name of the sequence from the name of the table and the id column.
>
> We use this in our php framework
>
>         function insert_id()
>         {
>                 global $pg_conn;
>                 if(isset($pg_conn)) {
>                         $query = sprintf("SELECT currval('%s_%s_seq')
> AS id",$this->table,$this->id_column);
>                         $result = @pg_query($pg_conn,$query);
>                         $row = pg_fetch_assoc($result);
>                         return strval($row["id"]);
>                 } else {
>                         return 0;
>                 }
>         }

Thanks, but this demands you to have the table and id_column name in
your hand, and I don't right now.

Also ... the "currval" function are specifik to postgresql, and there
are nothing like it in mysql that can make any garanti for getting row
for newly inserted data. You can access autoincrement values in mysql,
but no garanties are given about its value (someone else have inserted a
new in the same table).

But thanks for your interrest., anyway.

/BL

pgsql-general by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: OID Usage
Next
From: Bo Lorentsen
Date:
Subject: Re: OID Usage