#1 2011-05-28 23:34:40

gclaxton
Member
Registered: 2011-05-23
Posts: 6

Check for Empty Tables

What would the best way to test for an empty table, without throwing an exception?

Offline

#2 2011-05-29 14:29:20

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,269
Website

Re: Check for Empty Tables

What do you call "empty"?

You have the TSQLRest.TableRowCount(aClass) method to retrieve the row count.

Then the low-level TSQLDataBase.GetTableNames method to retrieve the list of existing tables. If your table is not in the list, the the table does not exist yet.
See  TSQLRestServerDB.CreateMissingTables about how to use this method.
But in our ORM you should not have to use such low-level trick, but uses the TSQLModel.GetTableIndex() method to check that a table is in the current database model.

Offline

Board footer

Powered by FluxBB