Question

How to detect/report a non-existent layer being queried with a FeatureReader (layer name is passed to FeatureReader in an attribute)


Badge +7

I am building a Workspace which takes an integer as one of it's parameters. Depending on the value of the parameter it will query a different ArcSDE layer.

 

I have an AttributeValueMapper to map the number to the layer name e.g.

Number : LayerName

1 : dbo.layerA

2 : dbo.layerB

etc

 

After this I have a FeatureReader where the Feature Types to Read value is set to @LayerName as set above. This all works nicely - the data comes out of the Generic port.

 

However, I also want to detect and report on any layers that don't exist. So if dbo.layerA is being set in the AttributeValueMapper but does not exist in ArcSDE, how do I detect this? I thought it would come out of the Rejected port of the FeatureReader, but it doesn't. I do get a WARNing line in the log saying the layer could not be found in the geodatabase, but there is seemingly nothing I can use in the Workspace.

 

I already have a NoFeaturesTester attached to the Generic port to handle a successful query of the layer that returns no results.

 

The only thing I can think of is attaching a NoFeaturesTester to the Schema port of the FeatureReader. With a valid layer, I get something out of this port. When I test a non-existent layer name, nothing comes out of the Schema port.


5 replies

Userlevel 3
Badge +26

What if you read in everything, and then tested fme_feature_type against the parameter? I believe this would work, but could present some overhead time depending on your data size.

 

EDIT: This is where a Max FeatureTypes to Read would come in handy for the FeatureReader. If you could limit the features read to 1 per feature type, you could very quickly test for the layer not existing in the DB. An Idea has been posted here: AC Idea: Add a "Max Feature to Read Per Feature Type" parameter to the FeatureReader (safe.com)

Userlevel 1
Badge +21

Are you using a single feature to initiate and read multiple feature classes or a feature per featureclass? Do you need to distinguish between featureclasses that exist and have no features and featureclasses that don't exist?

Badge +7

That's a nice idea - I could read the ArcSDE table registry table and compare the layer names that way, which would be less of an overhead as it would not require reading all the data. Thanks :-)

Badge +7

Are you using a single feature to initiate and read multiple feature classes or a feature per featureclass? Do you need to distinguish between featureclasses that exist and have no features and featureclasses that don't exist?

Good question. Each time the Workspace is run, it should only have 1 point feature as an input. So there will only be a single feature initiating the FeatureReader and only 1 feature class being read from it.

Userlevel 1
Badge +21

Good question. Each time the Workspace is run, it should only have 1 point feature as an input. So there will only be a single feature initiating the FeatureReader and only 1 feature class being read from it.

If you are always only trying to read one featureclass, you can test the output from the initiator port, this will have _matched_records as zero if there are no records in the feature class or the feature class does not exist.

 

If you need to distinguish between zero records and a featureclass not existing, i would use the no features tester (or similar) on the schema port as you suggested.

Reply