Re: Temporary table
Posted in 2003
Sauron wrote:
> Hi, All!
>
> :((
> I repeat my question by example:
>
> ------------------
> create procedure _p1()>
> create temp table _t1 (a int);>
> insert into _t1 values(1);>
> end procedure;
> .........
> .........
> .........
> create procedure _p2()>
> if not exists (*) then
> call _p1();
> end if;
>
> end procedure;
> ------------------
>
>
>
> * - select temp_table_name from ... where sesionid = dbinfo('sessionid') and
> temp_table_name = '_t1'
>
>
> I hope, you will undestand me now...
>
>
>
> I know one solution:
>
> -------------
> begin
> on exception
> end exception;
>
> create temp table _t1 (a int);> end;
> ------------
>
> But must be solution by system tables using.
> For example, the following script returns all TEMP tables from instance:
>
> select tn.tabname[1,18] temp_table, tn.dbsname[1,18] db_name, s.name[1,14]
> dbspace, tn.owner[1,18]
> from sysmaster:systabnames tn, sysmaster:systabinfo ti,
> sysmaster:sysdbspaces s
> where tn.partnum = ti.ti_partnum
> and s.dbsnum = sysmaster:partdbsnum(ti_partnum)
> and (sysmaster:bitval(ti_flags,32) = 1 or
> sysmaster:bitval(ti_flags,64) = 1)
>
>
>
> --
> Sauron
>
>
I'm not sure about this, but I would say that an alternative is to always try to create the table.
You you get an error saying that the table already exists you then know that it existed before.
Regards.