Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread if temporary table exists
Mon, Nov 12 2007 12:03 PMPermanent Link

L Duncan
I am trying to find out if a temporary table exists before
dropping it and creating again using the following code:

with memorydatabase do
     begin
        Connected := True;
        Open;
        //if the memory table exists then drop
        if (Execute('SELECT * FROM Information.Tables WHERE Name='+Engine.QuotedSQLStr('PlanHoldings'))=1) then
           Execute('DROP TABLE "PlanHoldings"');
        Execute('CREATE TEMPORARY TABLE ...');
        Close;
     end;

Unfortunately I think it is the if (Execute('SELECT * FROM Information.Tables WHERE Name='+Engine.QuotedSQLStr('PlanHoldings'))=1) then

that is not picking up the existence of the table, although I do get errors stating it exists when I try and create it.

regards
Mon, Nov 12 2007 7:33 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

<< Unfortunately I think it is the if (Execute('SELECT * FROM
Information.Tables WHERE Name='+Engine.QuotedSQLStr('PlanHoldings'))=1) then

that is not picking up the existence of the table, although I do get errors
stating it exists when I try and create it. >>

Temporary tables do not show up in the catalog tables.  You'll have to just
enclose the DROP TABLE statement inside of an EXCEPTION block:

BEGIN
   EXECUTE IMMEDIATE 'DROP TABLE...';
EXCEPTION
END

--
Tim Young
Elevate Software
www.elevatesoft.com


Tue, Nov 13 2007 6:40 AMPermanent Link

L. Duncan
"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote:

BEGIN
   EXECUTE IMMEDIATE 'DROP TABLE...';
EXCEPTION
END

Thank you, much appreciated.

regards


Image