Question

FME 2018 FMW reader Parameter value SQL_STATEMENT format


Badge +1

In FME 2018 when reading out the SQL_STATEMENT from the Transformer Parameters reader, the SQL comes out formatted roughout like this example:

SELECT<space><lf>SITE_ID_FS<comma><lf>LIFEFORM<comma><lf>PLANT_CODE<comma>

 

<space><space><space><space><space><space><space>from<space>my_table<lf><space>

 

where <space> LIFEFORM <space>= <space><apos>TR<apos>

 

Is there an easy way to decode this back to a simple text that will run again in a SQL window ?

It looks like FME 2019 handles this better, but I am limited to 2018 for now.


2 replies

Userlevel 4

Try the following in a PythonCaller:

import fmeobjects

def decode_fme_encoded_string(feature):
    text = feature.getAttribute('sql')
    if text:
        decoded = fmeobjects.FMESession().decodeFromFMEParsableText(text)
        feature.setAttribute('sql', decoded)

Assuming that the attribute name is 'sql'.

Badge +1

Thanks,much appreciated

Reply