Page 1 of 2

Check if Table exists

Posted: 19.07.2006, 10:40
by bart57
Hi,

How can I easily check if a Table exists ? (No Select and No TZTable.open + exception) ?


thx

Posted: 19.07.2006, 17:48
by gto
TZConnection have a GetTableNames function, which returns the name of all tables.. try it :)

Posted: 19.07.2006, 19:06
by zippo
At least two ways:

Execute a query "Show Tables like "teblename%" and see if there's your table.

Use ZSQLMetadata component to do it.

Posted: 20.07.2006, 09:32
by bart57
Thank you,

it works fine :-)

Posted: 21.07.2006, 12:40
by bart57
Hi Zippo,

how does it work with ZSQLMetadata, have you an example please?


thx

Posted: 22.07.2006, 21:28
by Terence
Var List:TStringList;
List:= TStringList.Create;
Connection.GetTableNames('tablename%',string; List);
......
List.Free;

Posted: 24.07.2006, 07:27
by bart57
I know how it works with GetTableNames but I ask how it works with ZSQLMetadata

Posted: 24.07.2006, 07:31
by Terence
GetTableNames is implemented in/as ZSqlMetaData

Posted: 24.07.2006, 10:04
by bart57
thx but GetTableNames give me all the tables back !
I just want the tables from one shema !

Posted: 24.07.2006, 10:17
by Terence
That is there is a filter param for that method, check
Connection.GetTableNames('shema%',List);

Posted: 24.07.2006, 11:05
by bart57
thx,

I have a problem: the name of my shema is BISS, I try

zConnection1.GetTableNames('BISS%',List);

but it doesn't work :-(

Posted: 24.07.2006, 11:55
by Terence
Then apply my patch on Testing branch,compile zeos and call
ZConnection.GetTableNames('BISS','',List);
afterwards.

If it works for you, i will commit.

Posted: 24.07.2006, 12:30
by bart57
thx a lot Terence ,

It works great with your modified Procedure! :)

Posted: 24.07.2006, 12:35
by Terence
which databse did you use - i need the info just for commit statment.

Posted: 24.07.2006, 14:46
by bart57
I use Oracle 10g