dynamic table naming in function

Поиск
Список
Период
Сортировка
От Matthew Peter
Тема dynamic table naming in function
Дата
Msg-id 20051029174521.89306.qmail@web35210.mail.mud.yahoo.com
обсуждение исходный текст
Ответы Re: dynamic table naming in function  (Bruno Wolff III <bruno@wolff.to>)
Re: dynamic table naming in function  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Out of curiosity, I was wondering if it is possible to
use dynamic table names in a function? AND whether or
not you can test a value prior to insert to see
whether or not you want to update that column. Where
you could pass in the name of the table for it use ANY
name passed in rather than statically defining it.

I'll try an example of what I'm thinking;

CREATE OR REPLACE FUNCTION updatefoo(tbl_prefix
varchar, data  mydata, myid bigint) RETURNS
boolean AS $$
DECLARE
BEGIN
    update ${tbl_prefix}rest_of_table_name  set
    f1 = mydata.f1
    IF LEN mydata.f2 THEN   -- this possible? to
update f2 ONLY if it contains data?
        ,f2 = mydata.f2
    END IF;
    WHERE id  = myid;

     IF NOT FOUND THEN
         return false;
     END IF;
     return true;
END
$$ LANGUAGE plpgsql;



__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com

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

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: function that resolves IP addresses
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: dynamic table naming in function