X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E9FB8D1B49B for ; Fri, 19 Dec 2003 12:15:54 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 92946-06 for ; Fri, 19 Dec 2003 08:15:07 -0400 (AST) Received: from beta.fastwebnet.it (beta.fastwebnet.it [213.140.2.43]) by svr1.postgresql.org (Postfix) with ESMTP id A7B77D1B4A6 for ; Fri, 19 Dec 2003 08:15:03 -0400 (AST) Received: from ropelxp (1.40.84.105) by beta.fastwebnet.it (6.7.019) id 3FA22C8A005EC8BB for pgsql-odbc@postgresql.org; Fri, 19 Dec 2003 13:15:00 +0100 Message-ID: <029601c3c629$d8a310f0$0100a8c0@ropelxp> From: "Ropel" To: "postgre" References: <006201c3c622$682a5ba0$0f32a8c0@denisnew> Subject: Re: get last oid Date: Fri, 19 Dec 2003 13:08:50 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/58 X-Sequence-Number: 3596 Wanderful!!! I never thought about this !! Roberto ----- Original Message ----- From: "sqllist" To: "postgre" Sent: Friday, December 19, 2003 12:22 PM Subject: Re: [ODBC] get last oid > Hi Ricky, > > There is a work around for this... > > 1. Create a LOCAL TEMPORARY table. > 2. On the MAIN table, put a trigger to store NEW.oid in that TEMPORARY > table. > 3. On your VB application, Fetch OID from that TEMP table. > > Since, the local temporary table's data is visible to specific to session, > each session will get their OID even if "n" numbers of users are inserting > data in that table at a time.. > > HTH > > Thanx > > Denis > > > > ----- Original Message ----- > > From: "Ropel" > > To: "postgre" > > Sent: Friday, December 19, 2003 2:32 PM > > Subject: Re: [ODBC] get last oid > > > > > > > ... 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" > > > To: "postgre" > > > 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" > > > > To: "postgre" > > > > 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" > > > > > To: "postgre" > > > > > 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 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match