Re: Updating

Поиск
Список
Период
Сортировка
От Harvey, Allan AC
Тема Re: Updating
Дата
Msg-id E97A5BB7699CAD48BE2711E71247116502F8942C@ntlmsg03.onesteel.com
обсуждение исходный текст
Ответ на Re: Updating  (Bob Pawley <rjpawley@shaw.ca>)
Список 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,
pleaseadvise the sender and delete the document. Neither OneSteel nor the sender accept responsibility for any viruses
containedin this email or any attachments. 

В списке pgsql-general по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: Updating
Следующее
От: tuanhoanganh
Дата:
Сообщение: array function problem