Skip to main content
Question

Build SQL instructions with FME functions like @DateTimeFormat

  • November 23, 2018
  • 4 replies
  • 47 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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

redgeographics
Celebrity
Forum|alt.badge.img+60
  • Celebrity
  • 3702 replies
  • November 23, 2018

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
  • 19 replies
  • 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+44
  • Influencer
  • 3429 replies
  • 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.

Why not create the timestamp in sql?


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

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.