Re: [despammed] Destination table by variable?

Поиск
Список
Период
Сортировка
От Andreas Kretschmer
Тема Re: [despammed] Destination table by variable?
Дата
Msg-id 20050318154526.GG23980@webserv.wug-glas.de
обсуждение исходный текст
Ответ на Destination table by variable?  ("Erik Dahlstrand" <df03daer@ing.hj.se>)
Список pgsql-novice
am  18.03.2005, um 15:35:37 +0100 mailte Erik Dahlstrand folgendes:
> Hi!
>
> I want to choose the destination table by a variable. Something like this:
>
> CREATE FUNCTION insert_this(int4, varchar, varchar) RETURNS void AS $$
>     DECLARE
>         destTable text;
>     BEGIN
>         SELECT INTO destTable get_table_name($1);
>
>         INSERT INTO destTable VALUES ($2, $3);
>     END;
> $$ LANGUAGE plpgsql;
>
> Is it possible?

Yes, you can build your SQL as string and then execute this with
EXECUTE.
http://www.postgresql.org/docs/7.4/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN


Andreas
--
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47212,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
 ===    Schollglas Unternehmensgruppe    ===

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

Предыдущее
От: Afton & Ray Still
Дата:
Сообщение: Re: Destination table by variable?
Следующее
От: Andreas Kretschmer
Дата:
Сообщение: Re: [despammed] Re: Destination table by variable?