Skip to main content
Question

How to search for just part of FME Feature attribute name?

  • December 12, 2016
  • 3 replies
  • 13 views

I have exposed the fme_feature_type attribute.

I am then using the FeatureWriter to write this feature class (FGDB) to POSTGIS.

Its new name in POSTGIS is @LowerCase(@Value(fme_feature_type))_load.

My next transformer is the SQLExecutor where I am trying to find if the above table already exists but doesn't have the _load at the end and DROP that table if it does exist

So for example. I am loading Cities_load but want to drop the existing Cities table if it exists and then RENAME the Cities_load to Cities.

What would my SQLExecutor read?

DROP TABLE IF EXISTS @ReplaceString(@Value(_feature_type{0}.name), '_load', ''); ALTER TABLE @Value(_feature_type{0}.name) RENAME TO @ReplaceString(@Value(_feature_type{0}.name), '_load', '');

The above SQL doesn't seem to work correctly...

 

3 replies

erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • December 12, 2016

I would create a new attribute (DROP_TABLE), copy the value of fme_feature_type in that attribute and then use the StringReplacer to replace "_load" with nothing. Then use that attribute in the SQL statement avoiding the functions in the statement.


erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • December 12, 2016

Or use the SubstringExtractor as shown in the image (replace Test_load with attribute containing table name and result attribute to be DROP_TABLE):


  • Author
  • December 12, 2016
erik_jan wrote:

Or use the SubstringExtractor as shown in the image (replace Test_load with attribute containing table name and result attribute to be DROP_TABLE):

@erik_jan, I can tell that the correct renaming is occurring by looking at the logfile. Thanks for the SubStringExtractor tip.

 

 

but I am still getting this error.

 

 

Error executing SQL command ('ALTER TABLE energy_land_northamerica.cities_load

 

RENAME TO energy_land_northamerica.cities'): 'ERROR: syntax error at or near "."

 

LINE 2: RENAME TO energy_land_northamerica.cities...

 

^

 

'

 

A fatal error has occurred. Check the logfile above for details

 

 

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings