in query variables....
Hi all,
this is from the is there a way file.
Is there a way to get the name of the relation or relations in a query
from within the query? Like some kind of magic variable...?
for example :
"select *, <some_magic_variable> from thistable"
where <some_magic_variable> would be replaced by thistable.
Rhys
Peace & Love|Live Long & Prosper
Hi all,
this is from the is there a way file.
Is there a way to get the name of the relation or relations in a query
from within the query? Like some kind of magic variable...?
for example :
"select *, from thistable"
where would be replaced by thistable.Rhys
Peace & Love|Live Long & Prosper
No as far as I know, but you can create a stored procedure and pass
as parameter the table and then "create" your own query and
execute it from within the stored procedure
http://www.postgresql.org/docs/8.2/static/plpgsql-statements.html
EXECUTE 'UPDATE '|| some_magic_variable || ' SET '
|| quote_ident(colname)
|| ' = '
|| quote_literal(newvalue)
|| ' WHERE key = '
|| quote_literal(keyvalue);
I haven't tried it thought.
_________________________________________________________________
Tenemos lo que búscas…JUEGOS.
http://club.prodigymsn.com/
Rhys A.D. Stewart escribi�:
Is there a way to get the name of the relation or relations in a query
from within the query? Like some kind of magic variable...?
for example :
"select *, <some_magic_variable> from thistable"
where <some_magic_variable> would be replaced by thistable.
select *, tableoid::regclass from thistable
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support