Обсуждение: dynamic table/col names in plpgsql

Поиск
Список
Период
Сортировка

dynamic table/col names in plpgsql

От
"gary jefferson"
Дата:
Is there a way to use a variable as the name of a table or column in plpgsql?

This might be a simple question, but I can't find the answer in the
docs.  http://www.postgresql.org/docs/8.2/interactive/plpgsql-declarations.html
hints that there are data types that correspond to table/column, but I
don't see them listed here
http://www.postgresql.org/docs/8.2/interactive/datatype.html ...

Also, I assume that once I figure out the right datatypes, I can
assign to them from functions like substring()?

Thanks,
Gary

Re: dynamic table/col names in plpgsql

От
Martijn van Oosterhout
Дата:
On Sat, Jun 23, 2007 at 09:43:01PM -0600, gary jefferson wrote:
> Is there a way to use a variable as the name of a table or column in
> plpgsql?

No, plpgsql is statically typed, it can't handle the possiblity of the
types of variables changing. Use a more dynamic
language(perl/tcl/python/etc...)

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Вложения