BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Detect temp table

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO)
View previous topic :: View next topic  
Author Message
Jon Jacobs
Guest





PostPosted: Mon Aug 15, 2005 9:43 pm    Post subject: Detect temp table Reply with quote



D6, TADOQuery, MS SQL Server

I need to create and destroy temp tables (eg: #MyTableName).

Sometimes there is the possibility a temp table may be left around because of an exception elsewhare.

So I have to drop the table before I create it, just to be sure. Of course this creates an exception if the table does not
exist, so I have to surround the drop query with try..excpet, with an empty except clause.

All is smooth for the end user, but when debugging, the frequent exception breaks are quite annoying. I dare not turn off
the break on exception because I am usually looking for excpetions when debugging.

Is there a way to detect if a given named temp table exists? Then I could drop it only if it exists.

Thanks,

Jon

Back to top
Bryan Valencia
Guest





PostPosted: Mon Aug 15, 2005 10:02 pm    Post subject: Re: Detect temp table Reply with quote



Look for GetTableNames in the TADOConnection Help



"Jon Jacobs" <JonJacobsAtcomcast.net> wrote

Quote:
D6, TADOQuery, MS SQL Server

I need to create and destroy temp tables (eg: #MyTableName).

Sometimes there is the possibility a temp table may be left around because
of an exception elsewhare.

So I have to drop the table before I create it, just to be sure. Of course
this creates an exception if the table does not
exist, so I have to surround the drop query with try..excpet, with an
empty except clause.

All is smooth for the end user, but when debugging, the frequent exception
breaks are quite annoying. I dare not turn off
the break on exception because I am usually looking for excpetions when
debugging.

Is there a way to detect if a given named temp table exists? Then I could
drop it only if it exists.

Thanks,

Jon




Back to top
Jon Jacobs
Guest





PostPosted: Sat Aug 20, 2005 2:40 am    Post subject: Re: Detect temp table Reply with quote



Quote:
Look for GetTableNames in the TADOConnection Help
Thank you. Unfortunately, the TADOConnection only has information about the connection to a particular database. Temporarty

tables are in a different database, tempdb. The connection knows nothing about it. Thanks for trying.

Jon

Back to top
Dennis Passmore
Guest





PostPosted: Sun Aug 21, 2005 2:05 pm    Post subject: Re: Detect temp table Reply with quote

this is how I handle it,

just execute using the TADOConnection.execute( sqlcmd ) function and disregard the
results.


if object_id('tempdb..#tmptable') is not null -- may already exist because of
drop table #tmptable -- recursive stored procedure call below


Back to top
Jon Jacobs
Guest





PostPosted: Sun Aug 21, 2005 8:02 pm    Post subject: Re: Detect temp table Reply with quote

Quote:
just execute using the TADOConnection.execute( sqlcmd ) function and disregard the
results.


if object_id('tempdb..#tmptable') is not null -- may already exist because of
drop table #tmptable -- recursive stored procedure call below
Thanks. Addressing tempdb..#etc is the key. I appreciate it.


Jon

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.