From: | Tomas Vondra <tv(at)fuzzy(dot)cz> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Setting up functions in psql. |
Date: | 2007-02-16 13:37:57 |
Message-ID: | 45D5B3B5.1040206@fuzzy.cz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
>
> AutoDRS=# select "fnLoadAppraisals"();
> ERROR: relation with OID 18072 does not exist
> CONTEXT: SQL function "fnLoadAppraisals" statement 5
>
> 18072 is the OID of table appraisals_temp_load
>
> If I run the code within the function by itself, i.e. copy and paste
> the 6 lines of SQL int psql it runs fine... What precisely is this
> error telling me? It's not entirely clear to me.
>
This is caused by the fact that the function remembers OIDs once it's
parsed. So once it reaches the COPY, the original table (with the OID
18072) does not exist (the new table has a different one). This is a
feature, not a bug! You can bypass this using dynamic SQL, ie. use
EXECUTE 'DROP ...';
EXECUTE 'CREATE ...';
instead of plain DROP / CREATE. Dynamic SQL could be a performance
issue in some cases (as the query has to be parsed each time it's
executed) but this probably is not the case.
Tomas
From | Date | Subject | |
---|---|---|---|
Next Message | Bill Moran | 2007-02-16 13:50:32 | Re: how to hide database objects from users, that don't have access to them |
Previous Message | Stephen Frost | 2007-02-16 13:02:30 | Re: ROLE INHERIT |