In article <1994Aug12.194455.28517@pmafire.inel.gov>,
I posed the following problem:
>I have a function that creates a temporary table, inserts some records,
>and then uses it in a join with another table. Just before the function
>returns the temp table is dropped (i.e. I drop it with the drop
>command). So far, so good. But when a call is made a second time to my
>function (same invocation of the main routine, however) it generates
>the following error on the first insert into the temp table:
>
> Program stopped at "sel_out2.4gl", line number 115.
> SQL statement error number -710.
> Table (daveb.pref_pr) has been dropped, altered or renamed.
I received four responses -- all very good. Seems like this might be
something to put in a FAQ, so I thought I'd share them.
(Thanks to Mike Teachworth, Jonathan Leffler, Jack Parker and Bob Baskett
who took them time to respond.)
Here are the four suggestions:
1. Don't use TEMP TABLES, as they've always been a problem. Use a real
table and drop it when the program is done with it.
2. Be sure to re-prepare PREPARE statments if the temp table is dropped,
since when it is recreated it is, internally, a different table.
3. Perhaps an update statistics for the table is needed so that
systables is made aware of the table's current status.
4. Don't drop the TEMP TABLE. Use whenever error continue to plow
through the next (unnecessary) create temp table. The temp table exists
only for the duration of the program, anyway.
The first was a solution I could live with, the second didn't apply to
my problem, as I was re-preparing the PREPARE. I really jumped on the
third one -- it seemed a real likely solution, but I couldn't get it to
solve my problem. The last suggestion works great, and is the one I am
using, at least for now.
I'm still interested in a solution that isn't a work-around, but am
happy there is a work-around. Thanks for the help.
----------------------
Dave Black Idaho National Engineering Laboratory
daveb@dune.inel.gov Westinghouse Idaho Nuclear Company, Inc.
(208) 526-3355 Idaho Falls, ID