Re: Temporary tables
Posted in 1997
Uday Shankar wrote:
>
> Hi,
>
> I am looking for a way to detect if a temporary table
> already exists. I am creating temp tables in stored
> procedures and the informix manuals tell me that the
> tables will exist past the life of the stored procedure's
> execution.
>
> SO, I would like to find a way to detect if the
> temp table already exists and drop the old table
> if it does.
>
> It looks like the temporary table names are not registered
> in the system catalog table systables, so there doesn't
> appear to be any obvious way of checking to see if it
> exists or not.
>
> I checked the manuals and the IIUG FAQ and search engine
> but didn't find any mention of that.
>
> Thanks,
>
> Uday
> --
> Uday Shankar
> Derivative Products Group
> Republic National Bank of New York
> uday@dpg.rnb.com
> (212) 525-8000
Uday,
the following SP(with required changes) should do the trick:
create procedure testtemp(x char(10))
returning integer;define
i, cnt integer;
on exception in (-206) -- table not found ...
create temp table ttt (
f_col char(10));
insert into ttt values (x); end exception with resume;
insert into ttt values (x);
select count(*) into i from ttt; return i;
end procedure;
Hope this helps you.
--
\\\\|//
Vijay R. Anisetti |6 6|
-------------------oooO--U--Oooo----------------------------
oooO Oooo
( ) ( ) Just hangin on to this profession
---------------\\( -- )/-------------------------------------
\\) (/