Skip to main content
Solved

Comments in END_SQL statements ?


lifalin2016
Contributor
Forum|alt.badge.img+29

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.

View original
Did this help you find an answer to your question?

4 replies

takashi
Influencer
  • 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
Contributor
Forum|alt.badge.img+29
  • Author
  • Contributor
  • February 2, 2018
takashi wrote:

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
Contributor
Forum|alt.badge.img+29
  • Author
  • Contributor
  • February 21, 2018
lifalin2016 wrote:
(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
Contributor
Forum|alt.badge.img+29
  • Author
  • Contributor
  • Best Answer
  • June 21, 2022

Closing this as behaviour has changed in later versions.


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