Skip to main content

I would like to select only tables with certain strings in their table names when running a FeatureReader. So something akin to:

WHERE TABLE_NAME LIKE '%searchstring%'

Is this doable? And if so, how?

You can insert an SQLExecutor before the FeatureReader to query the database metadata tables. This depends on the database implementation, but for SQL Server it might look like this:

SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE' 
AND TABLE_CATALOG='MySchema'
AND TABLE_NAME LIKE '%searchstring%'

You could then pass the resulting attribute TABLE_NAME to the FeatureReader.

 


Thanks! 

And should anyone ever need to do this treatment on a geopackage file the syntax is:

SELECT TABLE_NAME
FROM GPKG_CONTENTS
WHERE TABLE_NAME LIKE '%yoursearchstring%'

One also needs to repeat the above in the 'attributes to expose field' to give the FeatureReader something to chew on. 


Alternatively, you can also use a FeatureReader set only to read the schema features (i.e. no data features), that way you'll get one feature per table / feature class in the source dataset, which you can then filter using a Tester/TestFilter before sending to the second FeatureReader.


Reply