Re: Access last inserted tuple info...

From: Luis D(dot) García <ldgarc(at)gmail(dot)com>
To: "David Fetter" <david(at)fetter(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Access last inserted tuple info...
Date: 2007-01-25 14:45:43
Message-ID: 3de424340701250645h6e91f9d2q7f7592c0bb43ada7@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks, I've heard that, but in this case won't exactly fit my needs...

..First, I'm working on a PostgreSQL 8.1.4 modification, and it
would be really difficult to add all the changes I've made to the
new version.

...Second, I need to do all this form the backend (Postgres
Source Code). I can't use any User or Administrator defined
functions or sometime like that.

Well, maybe I didn't make myself clear, this is what I need to do:

I need to know the values of some fields (columns) from the last
inserted tuple. The problem is that I need to do this in the moment
I'm inserting a new one (all from the backend code) and compare
the values between the new one (N.O) and the all ready inserted (A.R.I),
and if the N.O fits some properties (according to the A.R.I) it must
be decided if it has to be finally inserted or not.

I think there's not to much difficulty on that, but until now I haven't
found how to access that information. I can reach the HeapTuple
structure according the A.R.I tuple, but I don't know how to access
the information (values for its attributes) stored on it.

Thanks again...

2007/1/24, David Fetter <david(at)fetter(dot)org>:
>
> On Wed, Jan 24, 2007 at 12:56:14PM -0400, Luis D. Garc?a wrote:
> >
> > Hi, I'm working on a modification of PostgreSQL 8.1.4 and I need to
> access
> > the
> > information stored in the last tuple inserted in a table (All this
> from the
> > backend
> > code).
> > Could anyone please help me on this?
> > Greetings and Thanks...
>
> 8.2 has (INSERT/UPDATE/DELETE) ... RETURNING. Perhaps you could use
> the 8.2 series instead :)
>
> Cheers,
> David.
> --
> David Fetter <david(at)fetter(dot)org> http://fetter.org/
> phone: +1 415 235 3778 AIM: dfetter666
> Skype: davidfetter
>
> Remember to vote!
>

--
Luis D. García M.

Telf: (+58) 2418662663
Cel.: (+58) 4143482018

- FACYT - UC -
- Computación -

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nikolay Samokhvalov 2007-01-25 14:52:12 Proposal: allow installation of any contrib module simultaneously with Postgres itself
Previous Message Joe Conway 2007-01-25 14:41:34 crash on 8.2 and cvshead - failed to add item to the left sibling