Re: get last oid

From: "Ropel" <ropel(at)ropel(dot)it>
To: "postgre" <pgsql-odbc(at)postgresql(dot)org>
Subject: Re: get last oid
Date: 2003-12-19 09:02:57
Message-ID: 024501c3c60e$ebc9ab50$0100a8c0@ropelxp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

... In a well designed relational Db, every table has a (unique) primary
key: if so, you don't even need to
know the oid, because the record just inserted is directly reachable using
the PK.
If your PK uses sequences, you have to get the next seq value "select
nextval() from seq_xxxxx..." and use the
value obtained for inserting your new row instead of using it as a default
value; this way you are protected from
concurrent writing to the DB.

If you REALLY need the oid from the ODBC connection, I can't help... sorry !

Bye

Roberto

----- Original Message -----
From: "Ricky" <ricky(at)babonmultimedia(dot)com>
To: "postgre" <pgsql-odbc(at)postgresql(dot)org>
Sent: Friday, December 19, 2003 9:25 AM
Subject: Re: [ODBC] get last oid

> thanks Roberto,
>
> i'm new in vb and also in postgresql,
> well, if there'no function to get the last oid, how to catch the message
> INSERT 2237168 1 in visual basic ?
>
> if no, maybe i have to try to select the bigest oid to get it but i'm
> affraid while somebody insert in the same time, the oid will not match.
>
> you have suggestion about this?
>
> BR
>
> Ricky
>
>
> ----- Original Message -----
> From: "Ropel" <ropel(at)ropel(dot)it>
> To: "postgre" <pgsql-odbc(at)postgresql(dot)org>
> Sent: Friday, December 19, 2003 3:20 PM
> Subject: Re: [ODBC] get last oid
>
>
> > PHP uses "pg_last_oid() ": a reliable way because it work's at
connection
> > level (i.e. it will not be affected
> > by inserts made from other tasks or connections .
> > I'd try searching starting from there for a solution without php: every
> > other language i've seen has an equivalent solution.
> >
> > With "psql" you have:
> >
> > postgres=# insert into cars(name) values('lamborghini');
> > INSERT 2237168 1
> >
> > where 2237168 is the oid...
> >
> > I hope it willl help...
> >
> > Roberto
> >
> >
> > ----- Original Message -----
> > From: "Ricky" <ricky(at)babonmultimedia(dot)com>
> > To: "postgre" <pgsql-odbc(at)postgresql(dot)org>
> > Sent: Friday, December 19, 2003 1:05 AM
> > Subject: [ODBC] get last oid
> >
> >
> > > hello,
> > >
> > > i try get the last oid after INSERT command but i have no idea about
> > > command/function
> > > .anyone know or is there any better method?
> > >
> > > Thanks
> > > Ricky
> > >
> > >
> > > ---------------------------(end of
broadcast)---------------------------
> > > TIP 4: Don't 'kill -9' the postmaster
> >
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 4: Don't 'kill -9' the postmaster
> >
> >
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)

In response to

Responses

Browse pgsql-odbc by date

  From Date Subject
Next Message denis 2003-12-19 09:31:13 Re: get last oid
Previous Message Ricky 2003-12-19 08:25:23 Re: get last oid