Toad World® Forums

Format of invalid SQL


#1

This SQL will format, even though it is invalid and will not run. Is that by design?

select * from dual where a

Thanks.

-Charlie


#2

Hi Charlie,

I checked it with all formatter versions we have and this SQL could always be formatted. I have forwarded this question to the formatter team. I will update you once I hear from them.

Thanks,

Vincent


#3

This is by design. Text is formatted up to the first syntax error or (premature) end of text. In some cases formatting goes beyond syntax errors.

Andre


#4

Looking further at this, what I wrote above is true but your statement is a valid statement for the parser. The ‘a’ is interpreted as a boolean variable, which is a valid predicate.

To illustrate what I wrote, try to format the following:

select
*
from
dual
where

This should yield:

SELECT *
  FROM DUAL
 WHERE

Andre