Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 52ED19FB886 for ; Tue, 3 Apr 2007 11:26:37 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 10501-07 for ; Tue, 3 Apr 2007 11:26:17 -0300 (ADT) X-Greylist: delayed 00:17:52.016539 by SQLgrey-1.7.4 Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 6429D9FB844 for ; Tue, 3 Apr 2007 11:26:17 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from tamar.dmr.co.uk (tamar.dmr.co.uk [195.112.52.166]) by svr4.postgresql.org (Postfix) with ESMTP id 359AC5AF8A9 for ; Tue, 3 Apr 2007 14:08:22 +0000 (GMT) Received: from HFPORT.dmr.co.uk (pennsoft.gotadsl.co.uk [81.6.232.68]) by tamar.dmr.co.uk (8.13.5/8.13.5) with ESMTP id l33E81Wx015401; Tue, 3 Apr 2007 15:08:01 +0100 Message-Id: <200704031408.l33E81Wx015401@tamar.dmr.co.uk> X-Mailer: QUALCOMM Windows Eudora Version 7.1.0.9 Date: Tue, 03 Apr 2007 15:14:22 +0100 To: "Wilkinson, Jim" , From: Hilary Forbes Subject: Re: Using a variable as a view name in a select In-Reply-To: <7CCC5BEF5E72394C963E529B54EB4A642A19B3@SD01ITMV12.PROD.NET > References: <141386.39515.qm@web57105.mail.re3.yahoo.com> <7CCC5BEF5E72394C963E529B54EB4A642A19B3@SD01ITMV12.PROD.NET> Mime-Version: 1.0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.138 tagged_above=0 required=5 tests=BAYES_50=0.001, FORGED_RCVD_HELO=0.135, HTML_MESSAGE=0.001, MIME_HTML_ONLY=0.001 X-Spam-Level: X-Archive-Number: 200704/33 X-Sequence-Number: 28033 Jim

My initial reaction is what are you trying to achieve?  Surely you could have one underlying table with dates in it and

SELECT * from mytable WHERE date1>=3D'2007/04/01' AND date2<=3D'2007/05/01';

but otherwise, like John, I would use an external scripting language to create the table name.

Hilary

At 14:04 03/04/2007, Wilkinson, Jim wrote:

I have created a view, called april_may.   I need to select this view by combineing to fields in the database to create the view name etc =85
 
Create view as select * from table_X;
 
I need to do something like this =85
 
Select * from (select table.start_month||_||table.end_month);
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Start_month  =3D april
End_month =3D May
 
What I what to pass to the select is the combination of the 2 fields as the view name.
 
Any ideas ?

Hilary Forbes
DMR Limited (UK registration 01134804)
A DMR Information and Technology Group company ( www.dmr.co.uk)
Direct tel 01689 889950 Fax 01689 860330
DMR is a UK registered trade mark of DMR Limited
**********************************************************