Search Postgresql Archives

Re: Updating

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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@xxxxxxxxxxxxxx)To make changes to your subscription:http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux