Re: functions with plpgsql

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]





Bernd Hoffmann wrote:

Hallo Andy,


I do not think you can evaluate a declared vairable as a table name in the
SELECT statement.


where can I find some docu about declare a table by variable.

you need to do this as a dynamic query.

look in the pl/pgsql docs here
http://www.postgresql.org/docs/7.3/interactive/plpgsql-statements.html
and here
http://www.postgresql.org/docs/7.3/interactive/plpgsql-control-structures.html
for description of the FOR-IN-EXECUTE loop you need for dynamic SELECTs

basically it'll be something like

FOR myrecordvar IN EXECUTE ''select max(id) from '' || quote_ident(mytablenamevar) LOOP
	... do some stuff ...
END LOOP;




[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux