Re: Updating

From: "Harvey, Allan AC" <HarveyA(at)OneSteel(dot)com>
To: "Bob Pawley" <rjpawley(at)shaw(dot)ca>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Updating
Date: 2008-03-17 01:09:27
Message-ID: E97A5BB7699CAD48BE2711E71247116502F8942C@ntlmsg03.onesteel.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> Would it be possible to get an example of such coding??

This trigger has an argument passed. When the trigger is "assigned"
I know whether the column is of type txt or float.

It uses the column name to determine what to do.

Hope this helps Allan

create or replace function insert_if_diff() returns trigger as
$BODY$
declare
r record;

begin
for r in execute 'select ' || TG_ARGV[0] || ' from ' || TG_TABLE_NAME || ' order by dt desc limit 1;'
loop
if TG_ARGV[0] = 'value'
then
if new.value = r.value
then
return null;
end if;
end if;

if TG_ARGV[0] = 'txt'
then
if new.txt = r.txt
then
return null;
end if;
end if;

return new;
end loop;

return NEW;
end;

$BODY$
language plpgsql;

The material contained in this email may be confidential, privileged or copyrighted. If you are not the intended recipient, use, disclosure or copying of this information is prohibited. If you have received this document in error, please advise the sender and delete the document. Neither OneSteel nor the sender accept responsibility for any viruses contained in this email or any attachments.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2008-03-17 01:27:36 Re: Updating
Previous Message Bob Pawley 2008-03-17 00:36:35 Re: Updating