Skip to main content

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...

 

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.


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


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