Question

Rule based selection of tables in FeatureReader?

  • 28 April 2023
  • 3 replies
  • 0 views

Badge +14
  • Contributor
  • 120 replies

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?


3 replies

Userlevel 4

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.

 

Badge +14

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. 

Userlevel 4

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