Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Checking if table exists in EDB
Thu, Jul 30 2009 7:57 PMPermanent Link

"Adam H."
Hi,

I was wondering if anyone can please give me an example on how to see if a
table exists within EDB?

Looking at the manual it says "This property is no longer necessary. To
determine if a table or view exists in a database, query the special
Information Schema for the database.", but I can't find any additional in
the manual about how to query the Special Information Schema.

Thanks & Regards

Adam.

Thu, Jul 30 2009 8:18 PMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Adam,

You can test if a table exists searching the Information Schema, as follows:

  SELECT * FROM Information.Tables WHERE Name = 'YourTableName'


You can also define a Delphi function, like this:

Function TableExists(TableName: string): boolean;
begin
  Result :=
    EDBDatabase1.Execute(
      'SELECT Version '+
      'FROM Information.Tables '+
      'WHERE Name =' + QuotedStr(TableName)
    )=1 ;
end;

--
Fernando Dias
[Team Elevate]
Thu, Jul 30 2009 8:21 PMPermanent Link

Richard Harding
Adam

>>Looking at the manual it says "This property is no longer necessary. To determine if a
table or view exists in a database, query the special
Information Schema for the database.", but I can't find any additional in the manual about
how to query the Special Information Schema.

The following query will result in 1 if the <TableName> table exists, otherwise 0.

select Count(*) from Information.Tables
 WHERE Name = :TableName

Richard Harding
Fri, Jul 31 2009 12:29 AMPermanent Link

"Adam H."
Hi Guys,

And thanks for your help! Greatly apprecaited...

Adam.
Fri, Jul 31 2009 12:03 PMPermanent Link

"David Cornelius"
> I was wondering if anyone can please give me an example on how to see
> if a table exists within EDB?

You might also want to check out the "extensions" newsgroup.  There's a
TableExists function posted about a year back that might come in handy.

--
David Cornelius
CorneliusConcepts.com
Image