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

2008-03-13 Thread David Gagnon
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,

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

2008-03-13 Thread Craig Ringer
David Gagnon wrote: 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. Well, you can get half way there with SELECT ... INTO TEMPORARY TABLE tablename, eg: SELECT 1 AS n, TEXT

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

2008-03-13 Thread kevin
Quoting Craig Ringer [EMAIL PROTECTED]: David Gagnon wrote: 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. Well, you can get half way there with SELECT ... INTO TEMPORARY

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

2008-03-13 Thread Adrian Klaver
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

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

2008-03-13 Thread Colin Wetherbee
Adrian Klaver wrote: 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

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

2008-03-13 Thread Adrian Klaver
On Thursday 13 March 2008 2:46 pm, Colin Wetherbee wrote: Adrian Klaver wrote: 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

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

2008-03-13 Thread Colin Wetherbee
Adrian Klaver wrote: On Thursday 13 March 2008 2:46 pm, Colin Wetherbee wrote: Adrian Klaver wrote: 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

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

2008-03-13 Thread Tom Lane
Colin Wetherbee [EMAIL PROTECTED] writes: Adrian Klaver wrote: Try CREATE TEMP TABLE foo ON COMMIT DROP AS (SELECT 1 AS a, 2 AS b) ; I don't know what version the OP is using, but that doesn't work on 8.1: Seems to be there in 8.2 and up. regards, tom lane -- Sent

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

2008-03-13 Thread Colin Wetherbee
Tom Lane wrote: Colin Wetherbee [EMAIL PROTECTED] writes: Adrian Klaver wrote: Try CREATE TEMP TABLE foo ON COMMIT DROP AS (SELECT 1 AS a, 2 AS b) ; I don't know what version the OP is using, but that doesn't work on 8.1: Seems to be there in 8.2 and up. In 8.2: cww=# BEGIN; BEGIN

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

2008-03-13 Thread Colin Wetherbee
Colin Wetherbee wrote: Tom Lane wrote: Colin Wetherbee [EMAIL PROTECTED] writes: Adrian Klaver wrote: Try CREATE TEMP TABLE foo ON COMMIT DROP AS (SELECT 1 AS a, 2 AS b) ; I don't know what version the OP is using, but that doesn't work on 8.1: Seems to be there in 8.2 and up. In 8.2:

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

2008-03-13 Thread Tom Lane
Colin Wetherbee [EMAIL PROTECTED] writes: Colin Wetherbee wrote: cww=# CREATE TEMP TABLE foo ON COMMIT DROP AS (SELECT 1 AS a, 2 AS b); FWIW, the output of \h CREATE TABLE in both 8.1 and 8.2 suggest that this should be possible. \h CREATE TABLE AS is what describes this variant ...

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

2008-03-13 Thread Colin Wetherbee
Tom Lane wrote: Colin Wetherbee [EMAIL PROTECTED] writes: Colin Wetherbee wrote: cww=# CREATE TEMP TABLE foo ON COMMIT DROP AS (SELECT 1 AS a, 2 AS b); FWIW, the output of \h CREATE TABLE in both 8.1 and 8.2 suggest that this should be possible. \h CREATE TABLE AS is what describes this