Skip to main content
Solved

Comments in END_SQL statements ?

  • January 26, 2018
  • 4 replies
  • 118 views

lifalin2016
Supporter
Forum|alt.badge.img+40

Hi,

I just added an end-sql statement to some workspaces, each with a comment on the preceding line. The comment is a T-SQL line comment on a separate line, i.e. with prepended "--" (two dashes).

This fails, as it seems FME gobbles up the first dash before execution, rendering the complete statement invalid.

If this WAD og a bug ?

Is it possible to add comments as "/* ... */" instead, or would "--- ..." (i.e. 3+ dashes) work ?

It also doesn't look like line-feeds in the statement are respected, so maybe line comments are a complete no-go ?

Cheers

Lars

Best answer by lifalin2016

Closing this as behaviour has changed in later versions.

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

takashi
Celebrity
  • January 26, 2018

Hi @lifalin2016, there is an FME specific syntax says any error occurs while executing a SQL statement won't stop the translation (i.e. FME ignores the error) if the statement was preceded with a single hyphen.

"An individual statement may be preceded with a hyphen, indicating that errors should be ignored. The following example contains two SQL commands where errors from the first command will be ignored:FME_SQL_DELIMITER ;-SELECT * FROM TABLEA;SELECT * FROM TABLEB;" -- SQL Statement, Parameters, SQLExecutor HelpBecause of that, I think that FME removes the leading hyphen from any statement before passing the statement to a database engine and therefore it could cause the error you have observed on a comment statement starting with two hyphens.I don't consider it as a bug, but think it should be documented somewhere, or there is a room to improve the implementation not to remove the first hyphen if the line starts with two consecutive hyphens.

lifalin2016
Supporter
Forum|alt.badge.img+40
  • Author
  • Supporter
  • February 2, 2018

Hi @lifalin2016, there is an FME specific syntax says any error occurs while executing a SQL statement won't stop the translation (i.e. FME ignores the error) if the statement was preceded with a single hyphen.

"An individual statement may be preceded with a hyphen, indicating that errors should be ignored. The following example contains two SQL commands where errors from the first command will be ignored:FME_SQL_DELIMITER ;-SELECT * FROM TABLEA;SELECT * FROM TABLEB;" -- SQL Statement, Parameters, SQLExecutor HelpBecause of that, I think that FME removes the leading hyphen from any statement before passing the statement to a database engine and therefore it could cause the error you have observed on a comment statement starting with two hyphens.I don't consider it as a bug, but think it should be documented somewhere, or there is a room to improve the implementation not to remove the first hyphen if the line starts with two consecutive hyphens.
(adding as comment instead of answer)

 

Thanks Takashi.

 

That would explain it, although I didn't use SqlExecutor, so its embedded help wasn't readily available.

 

But yes, there's room for some improvement. My expectation in an SQL window designed for SQL Server commands would clearly be, that it supports standard T-SQL. At least having the FME "syntax extensions" be optionally added (e.g. with a checkbox) would go a long way to resolve expectations.

 

But summarizing, it seems that three dashes would indeed work, and /* ... */ would also work.

 

Cheers, and have a nice weekend.

 

 


lifalin2016
Supporter
Forum|alt.badge.img+40
  • Author
  • Supporter
  • February 21, 2018
(adding as comment instead of answer)

 

Thanks Takashi.

 

That would explain it, although I didn't use SqlExecutor, so its embedded help wasn't readily available.

 

But yes, there's room for some improvement. My expectation in an SQL window designed for SQL Server commands would clearly be, that it supports standard T-SQL. At least having the FME "syntax extensions" be optionally added (e.g. with a checkbox) would go a long way to resolve expectations.

 

But summarizing, it seems that three dashes would indeed work, and /* ... */ would also work.

 

Cheers, and have a nice weekend.

 

 

Actually, it's still not quite good.

 

Even when I know that a command will fail, and prepend the command with a dash, it still (when failing) gets logged as an error in the log file.

 

This is most irritating, as I assumed the dash would make FME ignore any errors. At least don't log it as an error, just as a warning.

 


lifalin2016
Supporter
Forum|alt.badge.img+40
  • Author
  • Supporter
  • Best Answer
  • June 21, 2022

Closing this as behaviour has changed in later versions.