| From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
|---|---|
| To: | jonathansfl <jonathanbrinkman(at)yahoo(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Re: Can't drop temp table in subfunction during cursor loop (being used by active queries) |
| Date: | 2011-06-13 15:32:47 |
| Message-ID: | BANLkTikFW-wTecAKivv2SZHwo_EnWbgZtg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Mon, Jun 13, 2011 at 8:35 AM, jonathansfl <jonathanbrinkman(at)yahoo(dot)com> wrote:
> How would I create a dynamic table name, using the loop increment as a
> parameter?
>
> DROP TABLE IF EXISTS tt_PERSONSTODEACTIVATE || v_iteration CASCADE;
>
> that doesn't work. don't think i can use a dynamic variable as a table name,
> so i can't build the table name as a variable. perhaps if the entire DROP
> TABLE is inside dynamic SQL and I execute entire script. could try that,
> although it's messy for such a simple problem.
>
> i still don't understand still why the TEMP tables are not acting TEMPORARY
> and are not going away when their loop ends.
'execute' is for that:
http://www.postgresql.org/docs/current/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN
temp tables go away when the database session exits.
merlin
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bruno Wolff III | 2011-06-13 16:48:58 | Bad link to beta2 source |
| Previous Message | jonathansfl | 2011-06-13 15:32:43 | Re: temp tables not dropping at end of script |