Formatter bug with inline comments?

The formatter is messing with my comments and apostrophes. It's injecting spaces in a double dash and losing it afterwards.

@@cmf_error_code_ref_mat.dld -- don't move me

changes to:

@@cmf_error_code_ref_mat.dld - - don 't move me

Resulting in the error:
string "'t move me" missing terminating quote (').

I may be about to learn something about comments trailing an @@ call. All of these blow with errors. It seems the Grok is no smarter than me so if anyone finds alternative documentation please share. I'm SQLPlus 19.3 on Windows.

@@file.dld /* Don't stop believin' just for a ' comment */
@@file.dld --/* --Don't stop believin' just for a ' comment */

Grok spew....

Key Points

  • @@ in SQL*Plus: The @@ command is used to execute a script from a file, similar to @, but it searches for the script relative to the directory of the calling script (useful for nested scripts).
  • -- Comments: The -- syntax denotes a single-line comment in SQLPlus (and SQL in general). Anything following -- on the same line is ignored by the SQLPlus parser, provided it’s processed as part of a valid SQL or SQL*Plus command.
  • Line Processing: SQL*Plus processes input line by line, and the presence of -- after @@ affects only the interpretation of that specific line.

Can -- Follow @@?

Yes, you can place a -- comment after an @@ command on the same line, and SQL*Plus will treat everything after -- as a comment, ignoring it. The @@ command itself (and its script reference) will still execute, provided the syntax before -- is valid.

Suprised that this one shows up after so many years ... :smiley:
Will fix it asap, of course (QP-4338)

@chazamania, "All of these blow with errors", the 2nd one fails of course, but am I right that the first one passes, at least I see no diff after formatting, other than the comment moved to the right margin?

Thanks for reporting,
Andre

@chazamania Grok is incorrect.

Comments are NOT valid after SQL*Plus commands. See the documentation:

Using SQL*Plus in Scripts, section 5.3.3:

For SQL*Plus commands, you can only include "--" style comments if they are on a line by themselves`

REMARK

A line cannot contain both a comment and a command.

I speak from experience, where scripts in SQL* Plus haven't executed correctly due to them. As I understand it, SQL* Plus parses its own commands differently than how the database engine parses SQL statements or PL/SQL blocks. Attempting to append comments to the end of a SQL* Plus command line will typically result in SQL* Plus not recognising the command correctly, or it might treat the entire line as a comment depending on the exact syntax and what follows. This can lead to unexpected errors or the command simply being ignored. SQL* Plus expects its commands to be followed by a newline character to signify the end of the command, unless the command syntax specifically allows for additional parameters on the same line. Adding a comment after a SQL* Plus command confuses its parsing.

1 Like