Re: how to use record type

From: "Jeff Eckermann" <jeckermann(at)verio(dot)net>
To: "Horst Herb" <hherb(at)malleenet(dot)net(dot)au>, <pgsql-novice(at)postgresql(dot)org>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: how to use record type
Date: 2001-08-17 14:18:10
Message-ID: 009401c12727$71b3a150$279c10ac@INTERNAL
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice pgsql-sql

I have encountered this problem (in a different context), and could not find
a way to insert entire rows/records in the way that you appear to want. But
it worked fine if I INSERTed explicitly, like:
INSERT INTO table VALUES (OLD.field1, OLD.field2, ..., OLD.fieldn);
That should work fine inside a plpgsql function.
----- Original Message -----
From: "Horst Herb" <hherb(at)malleenet(dot)net(dot)au>
To: <pgsql-novice(at)postgresql(dot)org>; <pgsql-sql(at)postgresql(dot)org>
Sent: Thursday, August 16, 2001 5:24 PM
Subject: Fwd: how to use record type

> I have difficulties understanding how to use variable of "record" or "row"
> type. How do I actually insert the variables OLD or NEW or a record type
into
> a table from within a trigger?
>
> Like doing the following:
>
> drop table th1;
> create table th1(
> id serial,
> text text );
>
> drop table th_audit;
> create table th1_audit(
> ts timestamp default now()
> ) inherits(th1);
>
> drop function thaudit();
> create function thaudit() returns opaque as '
> begin
> -- I want to insert OLD into th_audit - how do I do this???
> return NEW;
> end; ' language 'plpgsql';
>
> drop trigger ta on th1;
> create trigger ta before delete or update on th1
> for each row execute procedure thaudit();
>
> Reagrds,
> Horst
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>
>

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message harrold 2001-08-17 15:54:29 using the Text::Query perl module with postgresql
Previous Message Tom Lane 2001-08-16 22:55:42 Re: Queries seem to lock up shell session

Browse pgsql-sql by date

  From Date Subject
Next Message Oleg Lebedev 2001-08-17 18:19:52 Re: Nested JOINs - upgrade to 7.1.2
Previous Message Martijn van Oosterhout 2001-08-17 09:47:31 Re: Query Approach and performance