Re: TEMP tables - Mailing list pgsql-sql

From Tomasz Myrta
Subject Re: TEMP tables
Date
Msg-id 3E3E3C83.3010607@klaster.net
Whole thread Raw
In response to TEMP tables  (Lex Berezhny <LBerezhny@DevIS.com>)
List pgsql-sql
Lex Berezhny wrote:
> hi,
> 
> I have a plpgsql procedure that needs to create a temporary table, use
> it as a stack internally, and then disgard it when the procedure exits.
> 

<cut>

> What are the recommendations or solutions on using temporary tables
> inside functions on a per call basis?
> 
> thanks a lot,

Instead of Bruce solution you can:
1. Create your temporary table only once after you login into database.
Before each execution of your function just delete/truncate this temporary table.
You don't need to drop this table, because it is 
automatically dropped when the session is finished.

2. Use global table as a stack. Use some sessionid to indetify stack for
each procedure execution. Create index on sessionid. There is one more
advantage on this solution - you can use views without recreating them.


Regards,
Tomasz Myrta





pgsql-sql by date:

Previous
From: "David Durst"
Date:
Subject: Commenting PLPGSQL
Next
From: Tomasz Myrta
Date:
Subject: Re: Commenting PLPGSQL