Thread: Selecting from a dynamic name
I have asked this question before, but still I'm stuck.
How can I select from a table with a name that's returned by a function?
eg : I have a function named tablename() which return 'mytable'
If I already have a table called mytable, can I :
select * from tablename();
pgadmin2 returns an error :
ERROR : parser : parse error at or near "("
==
====
Best Regards
Jason Kwok
==============
====
====
Best Regards
Jason Kwok
==============
====
---
Virus Free
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.303 / Virus Database: 164 - Release Date: 2001/11/24
You could try writing another function to do the select, and construct the query using string manipulation...
Chris
-----Original Message-----
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org]On Behalf Of Jason Kwok
Sent: Friday, 30 November 2001 10:43 AM
To: pgsql-sql@postgresql.org
Subject: [SQL] Selecting from a dynamic nameI have asked this question before, but still I'm stuck.How can I select from a table with a name that's returned by a function?eg : I have a function named tablename() which return 'mytable'If I already have a table called mytable, can I :select * from tablename();pgadmin2 returns an error :ERROR : parser : parse error at or near "("==
====
Best Regards
Jason Kwok
==============
====
---
Virus Free
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.303 / Virus Database: 164 - Release Date: 2001/11/24