Select to view content in your preferred language

Query data from unknown set of tables within file Geodatabase

3315
5
Jump to solution
12-30-2013 04:20 AM
EvanLortie
Emerging Contributor
I will preface this with I am new to ESRI and the associated development kits.

I am trying to get at the data contained within a file Geodatabase with the constraint of not necessarily knowing what the table name(s) are to begin with.  This is proving quite difficult through this api.

The only method (OpenTable) to obtain a reference to a table via the Geodatabase object requires you to pass in a string of said table's name/id.  This creates a circular chicken/egg situation for me...

The second route I attempted was using the ExecuteSQL method, but that proved just as fruitless trying to obtain the table data without actually knowing any of the table names.  I tried several SQL iterations attempting to pull data from the tables either via a name wild card of a table index, none of which resulted in values -- just the invalid SQL error.  I am very SQL inexperienced so that is likely on me.  I was able to query the required data when I passed in the table name to my SQL statement.

"SELECT * FROM <tableName>" works with "tablexyz" not (* or sys.tables, etc)

Is there a way to obtain a reference to a table within a file Geodatabase without actually knowing the table's name?  The file Geodatabase might have multiple tables as well.  I am surprised there is not an enumeration or listing mechanic off the Geodatabase object for all of the contained tables.

Thanks for any insight
-Evan
0 Kudos
1 Solution

Accepted Solutions
LanceShipman
Esri Regular Contributor
See the geodatabase function GetChildDatasets. It will list all tables, feature classes, etc. in a file geodatabase.

View solution in original post

0 Kudos
5 Replies
MichaelVolz
Esteemed Contributor
Why don't you know the name of the table you are looking for?
0 Kudos
EvanLortie
Emerging Contributor
Because I am trying to make as generic as possible the toolset I am putting together for a user base that have both ESRI and non-ESRI applications.  If they were only ESRI users I would just be using the ArcObjects API...but since the vast majority of them are not, I am attempting to use the FGDB API.

There are use cases where one user might send a file geodatabase from their ESRI workspace to another user who is using another product but needs to visualize all/part of that data.  The second user might not know what the first user has named his tables...which gets back to my original question of is it possible to obtain table data from the File Geodatabase API without apriori (sp?) knowledge of the table name or am I SOL and I need to go find a different solution.

If there is a way to generate a listing of the table names contained within a file geodatabase via the API that would obviously work just fine.

This API seems to work quite well if you are creating/modifying tables that you have custody over.  If you are working off a dataset that you do not necessarily have full insight into, there appear to be some deficiencies.  Which is fine, because I have a feeling that's where ArcObjects is better suited to play.

Thanks
Evan
0 Kudos
LanceShipman
Esri Regular Contributor
See the geodatabase function GetChildDatasets. It will list all tables, feature classes, etc. in a file geodatabase.
0 Kudos
DavidSousa
Occasional Contributor
There is no getting around the requirement of knowing the name of a table before opening it.

But, there is a way to find out the names of all the tables in the database.  You need to call the GetChildDatasets function on the Geodatabase class.  It returns a vector of strings containing the table names.
0 Kudos
EvanLortie
Emerging Contributor
See the geodatabase function GetChildDatasets. It will list all tables, feature classes, etc. in a file geodatabase.


Merci -- this appears to work.  I didn't expect <geodatabase>.GetChildDatasets("\\","") would work. 

Thanks
Evan
0 Kudos