pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
SELECT INTO TEMP in Trigger?
4+ messages / 3 participants
[nested] [flat]

* SELECT INTO TEMP in Trigger?
@ 2003-04-11 22:05 ` Itai Zukerman <zukerman@math-hat.com>
  2003-04-11 22:15   ` Re: SELECT INTO TEMP in Trigger? Itai Zukerman <zukerman@math-hat.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Itai Zukerman @ 2003-04-11 22:05 UTC (permalink / raw)
  To: pgsql-sql

This seems to not be possible is plpgsql:

  SELECT DISTINCT A.x INTO TEMP X FROM A,B WHERE A.x=B.x;

Is there some way to create a temporary table in plpgsql?

-- 
Itai Zukerman  <http://www.math-hat.com/~zukerman/;




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: SELECT INTO TEMP in Trigger?
  2003-04-11 22:05 ` SELECT INTO TEMP in Trigger? Itai Zukerman <zukerman@math-hat.com>
@ 2003-04-11 22:15   ` Itai Zukerman <zukerman@math-hat.com>
  2003-04-15 21:36     ` Re: SELECT INTO TEMP in Trigger? Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Itai Zukerman @ 2003-04-11 22:15 UTC (permalink / raw)
  To: pgsql-sql

> This seems to not be possible is plpgsql:
>
>   SELECT DISTINCT A.x INTO TEMP X FROM A,B WHERE A.x=B.x;
>
> Is there some way to create a temporary table in plpgsql?

Just to clarify, this sort-of works HOWEVER:

  SELECT count(*) FROM X;
  DROP X;

The first time through the plpgsql the SELECT is fine.  Further times
it complains:

  ERROR:  pg_class_aclcheck: relation 8845807 not found

I guess it doesn't like dealing with a different X.  Should I use
FOR-IN-EXECUTE?  That seems ugly...

-- 
Itai Zukerman  <http://www.math-hat.com/~zukerman/;




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: SELECT INTO TEMP in Trigger?
  2003-04-11 22:05 ` SELECT INTO TEMP in Trigger? Itai Zukerman <zukerman@math-hat.com>
  2003-04-11 22:15   ` Re: SELECT INTO TEMP in Trigger? Itai Zukerman <zukerman@math-hat.com>
@ 2003-04-15 21:36     ` Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Bruce Momjian @ 2003-04-15 21:36 UTC (permalink / raw)
  To: Itai Zukerman <zukerman@math-hat.com>; +Cc: pgsql-sql


See the FAQ on creating temp objects in functions ... use EXECUTE.

---------------------------------------------------------------------------

Itai Zukerman wrote:
> > This seems to not be possible is plpgsql:
> >
> >   SELECT DISTINCT A.x INTO TEMP X FROM A,B WHERE A.x=B.x;
> >
> > Is there some way to create a temporary table in plpgsql?
> 
> Just to clarify, this sort-of works HOWEVER:
> 
>   SELECT count(*) FROM X;
>   DROP X;
> 
> The first time through the plpgsql the SELECT is fine.  Further times
> it complains:
> 
>   ERROR:  pg_class_aclcheck: relation 8845807 not found
> 
> I guess it doesn't like dealing with a different X.  Should I use
> FOR-IN-EXECUTE?  That seems ugly...
> 
> -- 
> Itai Zukerman  <http://www.math-hat.com/~zukerman/;
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
> http://archives.postgresql.org
> 

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: SELECT INTO TEMP in Trigger?
@ 2003-04-11 22:15 ` Dan Langille <dan@langille.org>
  1 sibling, 0 replies; 4+ messages in thread

From: Dan Langille @ 2003-04-11 22:15 UTC (permalink / raw)
  To: Itai Zukerman <zukerman@math-hat.com>; +Cc: pgsql-sql

On 11 Apr 2003 at 18:05, Itai Zukerman wrote:

> This seems to not be possible is plpgsql:
> 
>   SELECT DISTINCT A.x INTO TEMP X FROM A,B WHERE A.x=B.x;
> 
> Is there some way to create a temporary table in plpgsql?

Yes.

http://www.postgresql.org/docs/view.php?version=7.3&idoc=0&file=sql-
selectinto.html

-- 
Dan Langille : http://www.langille.org/




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2003-04-15 21:36 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-04-11 22:05 ` Itai Zukerman <zukerman@math-hat.com>
2003-04-11 22:15   ` Itai Zukerman <zukerman@math-hat.com>
2003-04-15 21:36     ` Bruce Momjian <pgman@candle.pha.pa.us>
2003-04-11 22:15 ` Dan Langille <dan@langille.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox