pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fred Parkinson <FredP@abag.ca.gov>
To: mfahey@enter.net
To: pgsql-odbc@postgresql.org
Subject: Re: Getting the last inserted id
Date: Fri, 12 Nov 2004 09:59:53 -0800
Message-ID: <s19489ac.059@groupwise.abag.ca.gov> (raw)

Mike

Personally, if you are trying to do what I think you are trying to do,
I accomplish it with a 'trick' (aka kludge).

When users open my Access 2000 app I add a record to an Access table
called 'sessions' and keep track of the session_id which is created. 
The postgres records I need id's from have the session id stored in them
at creation with the rest of the data, as well as a timestamp.

so I do the following to get the key value of the record I just
created:

MyNow = Now()

rsData.AddNew
....
rsData!creation_date = MyNow
rsData!session_id = MySession
....
rsData.Update

then I run a query which asks for the key value of the record with
session_id = MySession and creation_date = MyNow.

Works every time
Lots of luck

Fred


>>> Mike Fahey <mfahey@enter.net> 11/12/2004 9:36:23 AM >>>
So I guess the question still remains, how do you get the last inserted

id from a sequence?

I'm using access 2003 & postgres odbc 8.0.02


select @@IDENTITY seems to be MS Specific and not work with postgres.

calling currval has to be a pass-through query which makes it high 
complicated if at all
possible.

How does everyone else do this ?

How does any database maintain referential integrity if this doesn't
work?





---------------------------(end of
broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to
majordomo@postgresql.org)



view thread (3+ messages)  latest in thread

Message-ID: <s19489ac.059@groupwise.abag.ca.gov>
Permalink:  ../s19489ac.059@groupwise.abag.ca.gov/
Also on:    postgresql.org/message-id/s19489ac.059@groupwise.abag.ca.gov

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: FredP@abag.ca.gov, mfahey@enter.net
  Subject: Re: Getting the last inserted id
  In-Reply-To: <s19489ac.059@groupwise.abag.ca.gov>
  References: <s19489ac.059@groupwise.abag.ca.gov>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox