From: | Timothy Perrigo <tperrigo(at)wernervas(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | question about temp table in function |
Date: | 2004-11-16 19:39:45 |
Message-ID: | 448DD9A4-3807-11D9-9E7A-000A95C4F0A2@wernervas.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I'm working on a plpgsql function that creates and populates a
temporary table. I would like the function to first drop the temp
table, if it already exists. I'm not sure how to accomplish this,
though. My first inclination was to simply wrap the 'drop table'
command in an exception handling block and ignore the exception if the
table does not exist. I'm not sure what error condition to catch,
though, so rather than specifying a "WHEN" condition, I just had
something like the following:
begin
execute 'drop table my_temp';
exception
-- do nothing
end;
That didn't work; apparently the "WHEN" condition is necessary. What
condition should I be trapping for?
Is there a better way to accomplish this? I thought about querying
pg_tables, and seeing if a record exists. Would that be a better
approach?
Thanks,
Tim
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Fuhr | 2004-11-16 20:11:12 | Re: question about temp table in function |
Previous Message | Tom Lane | 2004-11-16 18:29:36 | Re: PGCLIENTENCODING behavior of current CVS source |