Re: Is there a way to elegantly do a : CREATE TEMP TABLE X AS SELECT .... ON COMMIT DROP

From: Adrian Klaver <aklaver(at)comcast(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Is there a way to elegantly do a : CREATE TEMP TABLE X AS SELECT .... ON COMMIT DROP
Date: 2008-03-13 21:03:33
Message-ID: 200803131403.33537.aklaver@comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thursday 13 March 2008 4:49 am, David Gagnon wrote:
> Hi all,
>
> I think the title says everything:-)
>
> I just what a way to create a TEMP for the current transaction only.
> If possible I don't want to create the TEMP table first, specify all
> column types, etc.
>
> CREATE TEMP TABLE _T_CR1 AS
> SELECT CRNUM, CRYPNUM, CRMONT, CRDATE, GLNUM, CRRRNUM, CRACNUM, GLDESC
> FROM CR INNER JOIN CS ON CR.CRNUM = CS.CSCRNUM AND CR.CRYPNUM = CS.CSYPNUM
> INNER JOIN GL ON CS.CSGLNUM = GL.GLNUM AND 1 = GL.GLSOCTRL
> WHERE CRYPNUM = companyId
> AND DATEDIFF(DY, CRDATE, GETDATE()) >= _AGELIMITE
> ON COMMIT DROP;
>
>
> Thanks for your help
> David

I am missing something here. What is wrong with the above statement?
--
Adrian Klaver
aklaver(at)comcast(dot)net

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Anton Andreev 2008-03-13 21:38:43 Question about the cluster command
Previous Message Dean Gibson (DB Administrator) 2008-03-13 20:26:53 Re: Can't rename an existnig DB because it doesn't exist???