X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0AFC5475AE4 for ; Tue, 18 Feb 2003 15:49:44 -0500 (EST) Received: from smtp013.mail.yahoo.com (smtp013.mail.yahoo.com [216.136.173.57]) by postgresql.org (Postfix) with SMTP id 3E790475ADE for ; Tue, 18 Feb 2003 15:49:43 -0500 (EST) Received: from psc.progress.com (HELO Yahoo.com) (janwieck@192.233.92.200 with plain) by smtp.mail.vip.sc5.yahoo.com with SMTP; 18 Feb 2003 20:49:44 -0000 Message-ID: <3E529BF0.D373AA9C@Yahoo.com> Date: Tue, 18 Feb 2003 15:47:44 -0500 From: Jan Wieck Organization: Home X-Mailer: Mozilla 4.8 [en] (Windows NT 5.0; U) X-Accept-Language: en,ru MIME-Version: 1.0 To: josh@agliodbs.com Cc: Mintoo Lall , pgsql-sql@postgresql.org Subject: Re: Drop temporary table only if it exists References: <20030214153413.24680.qmail@web14802.mail.yahoo.com> <3E526F86.69391A03@Yahoo.com> <200302181028.01599.josh@agliodbs.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/416 X-Sequence-Number: 11814 Josh Berkus wrote: > > Jan, > > > > How do I drop a temporary table ( or for that matter a sequence) only > > > if it exists or create them if they donot exist ? I want to do this > > > to avoid any errors > > > > I wonder what type of application cannot remember if it created a temp > > object or not during the lifetime of it's database connection. > > A real one, Jan. > > This sort of test is particularly necessary for Exception handling routines. > One wants the exception handler to drop all temporary obejcts for a clean > slate, but since an exception has occurred, one cannot be sure which objects > were created successfully. All temporary objects that need to persist across transactions should be created at session start. Everything else is created inside the transaction that needs it and is therefore automatically cleaned up. If there are gazillions of those session level temporary objects, I doubt that the database is really the right place to "cache" this sort of data. > > I've personally written several such routines. I never needed to. I might when I come around and create the next generation of PL that supports packages with package initialization functions and the like. Let's see ... Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com #