Beautifier error on nested case statements

MSA

Member
Beautifier fails with internal error on nested case statements see example.
Example:
SELECT CASE
WHEN :p1 = 4 THEN
CASE
WHEN :p2 IS NOT NULL THEN 1 ELSE 0
END
WHEN :p1 = 3 THEN
CASE
WHEN :p2 IS NOT NULL THEN 1 ELSE 0
END
ELSE 1 END
FROM dual
 
If you add parenthesis around the inner case expressions then the beautifier will not give an internal error. But it still looks horrible.

If the case expression is used in PL/SQL then the parenthesis are not needed. It just looks horrible in another way:

Code:
declare
  x pls_integer;
begin
  x := CASE WHEN :p1 = 4 THEN CASE WHEN :p2 IS NOT NULL THEN 1 ELSE 0 END WHEN :p1 = 3 THEN CASE WHEN :p2 IS NOT NULL THEN 1 ELSE 0 END ELSE 1 END;
end;
Enhancement request: beautifier shall handle nested case expresssion both in SQL and PL/SQL.

Note that nested case statements seems to be handled fine.
 
Back
Top