Table-name as parameter to plpgsql

Поиск
Список
Период
Сортировка
От Andreas Joseph Krogh
Тема Table-name as parameter to plpgsql
Дата
Msg-id 200707302335.16951.andreak@officenet.no
обсуждение исходный текст
Ответы Re: Table-name as parameter to plpgsql  ("Milen A. Radev" <milen@radev.net>)
Список pgsql-sql
The following function failes to compile:

CREATE OR REPLACE FUNCTION test_func(p_table_name VARCHAR) RETURNS VOID AS $$
BEGIN   INSERT INTO p_table_name(some_field) VALUES('some_value');
END;
$$ LANGUAGE plpgsql;

Gives:
ERROR:  syntax error at or near "$1"
LINE 1: INSERT INTO  $1 (some_field) VALUES('some_value')

Any hints on how to use function-parameters as table-names like I'm trying to
above?

--
Andreas Joseph Krogh <andreak@officenet.no>
Senior Software Developer / Manager
------------------------+---------------------------------------------+
OfficeNet AS            | The most difficult thing in the world is to |
Karenslyst Allé 11      | know how to do a thing and to watch         |
PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
0214 Oslo               | comment.                                    |
NORWAY                  |                                             |
Tlf:    +47 24 15 38 90 |                                             |
Fax:    +47 24 15 38 91 |                                             |
Mobile: +47 909  56 963 |                                             |
------------------------+---------------------------------------------+


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

Предыдущее
От: Andrew Sullivan
Дата:
Сообщение: Re: Connection Limit
Следующее
От: "Scott Marlowe"
Дата:
Сообщение: Re: Connection Limit