Re: PL/pgSQL and new table creation

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: PL/pgSQL and new table creation
Дата
Msg-id 200402041953.32203.josh@agliodbs.com
обсуждение исходный текст
Ответ на PL/pgSQL and new table creation  (Matthew Syvinski <matthew@techcelsior.com>)
Список pgsql-novice
Matt,

> But when I run it, I get the following error.
>
> WARNING:  plpgsql: ERROR during compile of sp_newtable near line 8
> ERROR:  $1 is declared CONSTANT

You can't use a variable in place of an object name, unless you execute the
query as a dynamic string, e.g.:

CREATE FUNCTION new_table(TEXT) returns INT as
'DECLARE tbname ALIAS for $1;
BEGIN
EXECUTE 'SELECT * INTO ' || newtable || ' FROM d_master';
RETURN 1;
END;' LANGUAGE plpgsql;

--
-Josh Berkus
 Aglio Database Solutions
 San Francisco


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

Предыдущее
От: Matthew Syvinski
Дата:
Сообщение: PL/pgSQL and new table creation
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: Inserting a Null date.