Re: Latest transcation

From: Jonathan Gardner <jgardner(at)jonathangardner(dot)net>
To: "Anagha Joshi" <ajoshi(at)nulinkinc(dot)com>
Cc: <pgsql-admin(at)postgresql(dot)org>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Latest transcation
Date: 2003-06-20 13:43:18
Message-ID: 200306200643.37298.jgardner@jonathangardner.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-sql

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Friday 20 June 2003 01:27, Anagha Joshi wrote:
> Yes...I'm aware of that and have tried also by maintaining extra table.
> But how to to the following:
> 1. If insertion takes place, I want to return to the client the
> values (with field names of course) which are inserted into the
> tables. In each case table might be different.
>

When you insert a single row, PostgreSQL returns the OID of that row. Just
follow up with a select (SELECT * FROM <your table> WHERE OID=<the oid>) and
you'll get all the info you need.

> 2. If modification takes places, I want to know the values which
> are modified with field names and return them to the client.
>

You can do that by checking what is different between the data you inserted
and the data you get from the select statement.

> More precisely,
> My C++ client --
> '
> '
> "
> Transcation begin
> insert/update query to the backend is fired.
> //control is tranferred to the trigger
> //After trigger procedure is executed, I want at this
> point the values inserted/modified so //as to pass them back
> Transcation end
> '
> '
>

I don't think it can work the way you would like it. Try this algorithm.

For insert:
1. Insert query is run. (Trigger, other table inserts/updates performed)
2. With the OID from the insert, select the data.

For Update:
1. Update query is run. (Triggers, etc, are run as well).
2. With the OID (or Primary Key), select the data you just updated.

You can turn these two procedures into a stored procedure pretty easily. This
way, all you do is call a stored procedure, and it will pass back all the
data you need. You get a free transaction block inside the stored procedure
as well.

- --
Jonathan Gardner <jgardner(at)jonathangardner(dot)net>
(was jgardn(at)alumni(dot)washington(dot)edu)
Live Free, Use Linux!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+8w95WgwF3QvpWNwRAsVgAKCu48FN0VkRvXc9a2d9Qc91YU6jaQCdG4h4
kH42h4oWrsh1f1Splm0KNkA=
=zOMj
-----END PGP SIGNATURE-----

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Mel Jamero 2003-06-20 16:12:10 Re: pgsql function doesn't work
Previous Message Lucas Brasilino 2003-06-20 13:18:15 pg_ctl reload makes postmaster read enviroment variables again??

Browse pgsql-sql by date

  From Date Subject
Next Message javier garcia - CEBAS 2003-06-20 17:33:35 Re: date question
Previous Message Anagha Joshi 2003-06-20 08:27:04 Re: Latest transcation