> 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.

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to