Re: Drop temporary table only if it exists

Поиск
Список
Период
Сортировка
От Jan Wieck
Тема Re: Drop temporary table only if it exists
Дата
Msg-id 3E529BF0.D373AA9C@Yahoo.com
обсуждение исходный текст
Ответ на Drop temporary table only if it exists  (Mintoo Lall <tlqmail@yahoo.com>)
Ответы Re: Drop temporary table only if it exists  (Josh Berkus <josh@agliodbs.com>)
Список pgsql-sql
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 #


В списке pgsql-sql по дате отправления:

Предыдущее
От: Jan Wieck
Дата:
Сообщение: Re: Trigger that will execute external program
Следующее
От: JBJ
Дата:
Сообщение: once again, sorting with Unicode