Skip to main content

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.

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


Thanks,much appreciated


Reply