X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0D143475E75 for ; Mon, 3 Feb 2003 04:56:50 -0500 (EST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by postgresql.org (Postfix) with ESMTP id 5DA1C476076 for ; Mon, 3 Feb 2003 04:55:34 -0500 (EST) Received: from klaster.net (pe201.krakow.cvx.ppp.tpnet.pl [213.76.40.201]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id E7CE12B742; Mon, 3 Feb 2003 10:49:12 +0100 (CET) Message-ID: <3E3E3C83.3010607@klaster.net> Date: Mon, 03 Feb 2003 10:55:15 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; PL; rv:1.1) Gecko/20020826 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: Lex Berezhny Cc: pgsql-sql@postgresql.org Subject: Re: TEMP tables References: <1044235551.2176.29.camel@buddha> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/48 X-Sequence-Number: 11446 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. > > 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