Re: How to cast a general record?

From: Martin Gainty <mgainty(at)hotmail(dot)com>
To: <ml-postgresql-20081012-3518(at)gheift(dot)de>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to cast a general record?
Date: 2009-01-01 14:36:22
Message-ID: BLU142-W5A0B1E8B0D0C10D55995CAEE50@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Gerhard-
It is good you covered INSERTS but I would replicate the Insert Trigger for Update event
Vielen Danke,
Martin

______________________________________________
Disclaimer and confidentiality note
Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission.

> Date: Thu, 1 Jan 2009 14:41:08 +0100
> From: ml-postgresql-20081012-3518(at)gheift(dot)de
> To: pgsql-general(at)postgresql(dot)org
> Subject: [GENERAL] How to cast a general record?
>
> Hello,
>
> I want to log with triggers or in functions, and these logs should be
> independet of the transaction. Beside i want to have the information
> which action was commited and which not.
>
> So my idea was to log into the same database with dblink, return the
> primary keys and add them into a commit table.
>
> But my problem is, that I do not now how to write the rule properly.
>
> My schema locks like this:
>
> CREATE TABLE log_msg (
> msg_id bigserial not null,
> msg text not null,
> constraint msg_pkey primary key (msg_id)
> );
>
> CREATE TABLE log_commit (
> msg_id bigint not null,
> constraint msg_pkey primary key (msg_id)
> );
>
> CREATE VIEW log AS
> SELECT log_msg.*, log_commit.msg_id IS NOT NULL AS commited
> FROM log_msg LEFT JOIN log_commit USING (msg_id);
>
> CREATE OR REPLACE RULE "insert_log" AS
> ON INSERT TO log DO INSTEAD
>
> -- now this is pseudo code:
> INSERT INTO log_commit (msg_id)
> SELECT dblink('dbname=samedb', 'INSERT log_msg (msg) VALUES ('
> || quote_literal(new.msg)
> || ') RETURNING msg_id');
>
> Regards,
> Gerhard

_________________________________________________________________
It’s the same Hotmail®. If by “same” you mean up to 70% faster.
http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_broad1_122008

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2009-01-01 18:33:56 Re: encoding of PostgreSQL messages
Previous Message Gerhard Heift 2009-01-01 13:41:08 How to cast a general record?