Re: Using a variable as a view name in a select

From: Hilary Forbes <hforbes(at)dmr(dot)co(dot)uk>
To: "Wilkinson, Jim" <Jim(dot)Wilkinson(at)cra-arc(dot)gc(dot)ca>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Using a variable as a view name in a select
Date: 2007-04-03 14:14:22
Message-ID: 200704031408.l33E81Wx015401@tamar.dmr.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

<html>
<body>
Jim<br><br>
My initial reaction is what are you trying to achieve?&nbsp; Surely you
could have one underlying table with dates in it and<br><br>
SELECT * from mytable WHERE date1&gt;='2007/04/01' AND
date2&lt;='2007/05/01';<br><br>
but otherwise, like John, I would use an external scripting language to
create the table name.<br><br>
Hilary<br><br>
At 14:04 03/04/2007, Wilkinson, Jim wrote:<br><br>
<blockquote type=cite class=cite cite=""><font size=2 color="#000080">I
have created a view, called april_may.&nbsp;&nbsp; I need to select this
view by combineing to fields in the database to create the view name etc
…<br>
&nbsp;<br>
Create view as select * from table_X;<br>
&nbsp;<br>
I need to do something like this … <br>
&nbsp;<br>
Select * from (select table.start_month||_||table.end_month);<br>
==================<br>
Start_month&nbsp; = april<br>
End_month = May<br>
&nbsp;<br>
What I what to pass to the select is the combination of the 2 fields as
the view name.<br>
&nbsp;<br>
Any ideas ?</font></blockquote>
<x-sigsep><p></x-sigsep>
Hilary Forbes<br>
DMR Limited (UK registration 01134804) <br>
A DMR Information and Technology Group company
(<a href="http://www.dmr.co.uk/" eudora="autourl"><font color="#0000FF">
<u>www.dmr.co.uk</a></u></font>) <br>
Direct tel 01689 889950 Fax 01689 860330 <br>
DMR is a UK registered trade mark of DMR Limited<br>
**********************************************************</body>
</html>

Attachment Content-Type Size
unknown_filename text/html 1.4 KB

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message John Summerfield 2007-04-03 14:16:13 A long-running transaction
Previous Message Peter Eisentraut 2007-04-03 13:57:33 Re: LOCK command inside a TRANSACTION