Ed Holloman
Member²
Hi,
I'd like to note that the features of the beautifier have improved markedly from 5.x to 6.x. I use it all the time and it's an extremely useful feature (version 6.0.5.931).
I have a few requests (challenges) for the code beautifier, which I think the following examples illustrate.
In addition to the following examples, would it be possible to have the option to make any declared constants appear as all caps when beautified?
Thanks for all the improvements.
Ed Holloman
I'd like to note that the features of the beautifier have improved markedly from 5.x to 6.x. I use it all the time and it's an extremely useful feature (version 6.0.5.931).
I have a few requests (challenges) for the code beautifier, which I think the following examples illustrate.
In addition to the following examples, would it be possible to have the option to make any declared constants appear as all caps when beautified?
Thanks for all the improvements.
Ed Holloman
Code:
-------------------------------------------------------------------------------
DECLARE
v_select VARCHAR2(200);
loc_tab my_tt; -- nested table of object type my_ot
BEGIN
-------------------------------------------------------------------------------
-- string representation of select statement
-- current beautifier result
v_select := 'SELECT a.col1,' || ' b.col1,' || ' c.col1' ||
' FROM tab1 a,' || ' tab2 b,' || ' tab3 c' ||
' WHERE a.col1 = b.col1' || ' AND b.col1 = c.col1';
-- preferred beautifier result (controlled by addition of '--' comment characters at end of each line)
v_select := 'SELECT a.col1,' || --
' b.col1,' || --
' c.col1' || --
' FROM tab1 a,' || --
' tab2 b,' || --
' tab3 c' || --
' WHERE a.col1 = b.col1' || --
' AND b.col1 = c.col1';
-------------------------------------------------------------------------------
-- collections, bulk collect into
-- current beautifier result
SELECT my_ot(col1, col2, col3, col4) BULK COLLECT
INTO loc_tab
FROM my_table;
-- preferred beautifier result; a little more readable
SELECT my_ot(col1, col2, col3, col4) --
BULK COLLECT
INTO loc_tab
FROM my_table;
-------------------------------------------------------------------------------
-- decode, nested CASE statements
-- Most of the time I like to have items one item per line (select list, table list in FROM clause, etc.) for readability
-- The notable exception is the decode() statement, which if one item per line, takes up more vertical space
-- than I'd like
SELECT decode(a.col1, -- current beautifier result
'val1',
1,
'val2',
2,
'val3',
3,
'val4',
4,
'val5',
5,
'val6',
6) sort_order,
decode(a.col1, -- preferred beautifier result
'val1', 1,
'val2', 2,
'val3', 3,
'val4', 4,
'val5', 5,
'val6', 6) sort_order2,
CASE -- single level CASE just fine
WHEN b.col1 > 0 THEN
'valid'
ELSE
'not valid'
END a,
CASE -- current beautifier result - nested CASE; difficult to read
WHEN b.col1 > 0 THEN
CASE
WHEN b.col1 < 10 THEN
'range1'
ELSE
'out of range'
END ELSE 'not valid' END b,
CASE -- preferred beautifier result - nested CASE
WHEN b.col1 > 0 THEN
CASE
WHEN b.col1 < 10 THEN
'range1'
ELSE
'out of range'
END
ELSE 'not valid'
END c,
FROM tab1 a,
tab2 b,
tab3 c
WHERE a.col1 = b.col1
AND b.col1 = c.col1;
-------------------------------------------------------------------------------
END;
-------------------------------------------------------------------------------