Skip to main content
Question

Build SQL instructions with FME functions like @DateTimeFormat

  • November 23, 2018
  • 4 replies
  • 25 views

Forum|alt.badge.img

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

4 replies

redgeographics
Celebrity
Forum|alt.badge.img+49

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?


Forum|alt.badge.img
  • Author
  • November 23, 2018

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.


ebygomm
Influencer
Forum|alt.badge.img+38
  • Influencer
  • November 23, 2018
christian_b wrote:

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?


Forum|alt.badge.img
  • Author
  • November 23, 2018
ebygomm wrote:

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.


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