Skip to main content

Hi,

Is it possible to use FME functions like @DateTimeFormat in SQL Editors ?

I would like to use the "SQL to run before write" field in my writer to create a backup of the destination table whose name contains the current date as suffix.

Example:

create table myschema.mytable_@DateTimeFormat(@DateTimeNow(), %Y%m%d)) as select * from myschema.mytable;

 

But this doesn't work, even with single or double quotes around the FME functions...

 

Thanks for any help,

Christian

I'm wondering if FME sends the content of that editor to the database as-is... what happens if you build the SQL query in an attribute first and then use that to fill the editor?


Thanks for the answer, I tried your proposition with an AttributeCreator that creates an attribute attSqlBeforeWrite that contains my SQL instruction. And I inserted only @Value(attSqlBeforeWrite) in the SQL Editor of "SQL to run before write".

 

This new attribute is filled correctly (with the correct suffix in my table name) but I got a syntax error near near "@" at the execution of the SQL to run before write.


Thanks for the answer, I tried your proposition with an AttributeCreator that creates an attribute attSqlBeforeWrite that contains my SQL instruction. And I inserted only @Value(attSqlBeforeWrite) in the SQL Editor of "SQL to run before write".

 

This new attribute is filled correctly (with the correct suffix in my table name) but I got a syntax error near near "@" at the execution of the SQL to run before write.

Why not create the timestamp in sql?


Why not create the timestamp in sql?

How would you do that ?

I'm not trying to build a value with a timestamp but a table name.


Reply