From pg@newhonest.com Fri Nov 30 02:42:39 2001 Received: from mail.newhonest.com (vp239045.uac62.hknet.com [202.71.239.45]) by postgresql.org (8.11.3/8.11.4) with ESMTP id fAU2gXm45231 for ; Thu, 29 Nov 2001 21:42:39 -0500 (EST) (envelope-from pg@newhonest.com) Received: from jason (jason.newhonest.com [192.168.1.2]) (authenticated) by mail.newhonest.com (8.11.2/8.11.2) with ESMTP id fAU2h9c19569 for ; Fri, 30 Nov 2001 10:43:09 +0800 Message-ID: <001001c17948$c916b7c0$0201a8c0@newhonest.com> From: "Jason Kwok" To: Subject: Selecting from a dynamic name Date: Fri, 30 Nov 2001 10:43:26 +0800 Organization: New Honest Technologies Ltd MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_000D_01C1798B.D7292EE0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-ECS-MailScanner: Found to be clean X-Archive-Number: 200111/428 X-Sequence-Number: 5810 This is a multi-part message in MIME format. ------=_NextPart_000_000D_01C1798B.D7292EE0 Content-Type: text/plain; charset="big5" Content-Transfer-Encoding: quoted-printable 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();=20=20=20=20 pgadmin2 returns an error : ERROR : parser : parse error at or near "(" =3D=3D =3D=3D=3D=3D Best Regards Jason Kwok =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D --- Virus Free Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.303 / Virus Database: 164 - Release Date: 2001/11/24 ------=_NextPart_000_000D_01C1798B.D7292EE0 Content-Type: text/html; charset="big5" Content-Transfer-Encoding: quoted-printable
I have asked this question before, but still I'm=20 stuck.
How can I select from a table with a name that's return= ed by a=20 function?
 
eg : I have a function named tablename() which return= =20 '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 "("
 
=3D=3D
=3D=3D=3D=3D
Best Regards
Jason=20 Kwok
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D
 

---
Virus Free
Checked by AVG anti-virus syst= em (http://www.grisoft.com).
Version: 6.= 0.303 /=20 Virus Database: 164 - Release Date: 2001/11/24
------=_NextPart_000_000D_01C1798B.D7292EE0-- From chriskl@familyhealth.com.au Fri Nov 30 03:37:03 2001 Received: from mail.iinet.net.au (symphony-05.iinet.net.au [203.59.3.37]) by postgresql.org (8.11.3/8.11.4) with SMTP id fAU3b3m46771 for ; Thu, 29 Nov 2001 22:37:03 -0500 (EST) (envelope-from chriskl@familyhealth.com.au) Received: (qmail 3909 invoked by uid 666); 30 Nov 2001 03:37:00 -0000 Received: from unknown (HELO houston.familyhealth.com.au) (203.59.231.6) by mail.iinet.net.au with SMTP; 30 Nov 2001 03:37:00 -0000 Received: (from root@localhost) by houston.familyhealth.com.au (8.11.6/8.11.6) id fAU3b0N83514 for pgsql-sql@postgresql.org; Fri, 30 Nov 2001 11:37:00 +0800 (WST) (envelope-from chriskl@familyhealth.com.au) Received: from mariner (mariner.internal [192.168.0.101]) by houston.familyhealth.com.au (8.11.6/8.9.3) with SMTP id fAU3avG83417; Fri, 30 Nov 2001 11:36:57 +0800 (WST) From: "Christopher Kings-Lynne" To: "Jason Kwok" , Subject: Re: Selecting from a dynamic name Date: Fri, 30 Nov 2001 11:37:28 +0800 Message-ID: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00D3_01C17993.63D2FE50" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) In-Reply-To: <001001c17948$c916b7c0$0201a8c0@newhonest.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Importance: Normal X-scanner: scanned by Inflex 0.1.5c - (http://www.inflex.co.za/) X-Archive-Number: 200111/429 X-Sequence-Number: 5811 This is a multi-part message in MIME format. ------=_NextPart_000_00D3_01C17993.63D2FE50 Content-Type: text/plain; charset="big5" Content-Transfer-Encoding: 7bit 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 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 ============== ==== --- Virus Free Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.303 / Virus Database: 164 - Release Date: 2001/11/24 ------=_NextPart_000_00D3_01C17993.63D2FE50 Content-Type: text/html; charset="big5" Content-Transfer-Encoding: quoted-printable
You=20 could try writing another function to do the select, and construct the quer= y=20 using string manipulation...
 
Chris
-----Original Message-----
From:=20 pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org]= On=20 Behalf Of Jason Kwok
Sent: Friday, 30 November 2001 10:43= =20 AM
To: pgsql-sql@postgresql.org
Subject: [SQL] Select= ing=20 from a dynamic name

I have asked this question before, but still I'm=20 stuck.
How can I select from a table with a name that's retu= rned by=20 a function?
 
eg : I have a function named tablename() which return= =20 'mytable'
If I already have a table called mytable, can I=20 :
 
select * from tablename();    <= /DIV>
 
pgadmin2 returns an error :
ERROR : parser : parse error at or near "("
 
=3D=3D
=3D=3D=3D=3D
Best Regards
Jason=20 Kwok
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
=3D=3D=3D=3D
=
 

---
Virus Free
Checked by AVG anti-virus sy= stem=20 (http://www.grisoft.com).
Versi= on:=20 6.0.303 / Virus Database: 164 - Release Date:=20 2001/11/24
------=_NextPart_000_00D3_01C17993.63D2FE50--