Re: What happened to SQL*Developer SQL Formatter?

  • From: Lothar Flatz <l.flatz@xxxxxxxxxx>
  • To: oracle-l@xxxxxxxxxxxxx
  • Date: Thu, 5 Nov 2015 19:27:12 +0100

/"Natural keys ALWAYS break."/

Yep. +1.


On 05.11.2015 18:15, Jeff Smith wrote:


Natural keys ALWAYS break.

Plural is the way to go.

*From:*Matt Adams [mailto:MAdams@xxxxxxxxxxxxxxxxxxx]
*Sent:* Thursday, November 05, 2015 11:23 AM
*To:* oracle-l
*Subject:* RE: What happened to SQL*Developer SQL Formatter?

I have better luck distracting them with a debate on natural vs. artificial primary keys. But that usually turns into a religious discussion too.

*From:*oracle-l-bounce@xxxxxxxxxxxxx <mailto:oracle-l-bounce@xxxxxxxxxxxxx> [mailto:oracle-l-bounce@xxxxxxxxxxxxx] *On Behalf Of *Niall Litchfield
*Sent:* Thursday, November 05, 2015 11:20 AM
*To:* Jeff Smith
*Cc:* jack.applewhite@xxxxxxxxxxxxx <mailto:jack.applewhite@xxxxxxxxxxxxx>; oracle-l
*Subject:* Re: What happened to SQL*Developer SQL Formatter?

That's OK - I can usually side track that by talking about object naming and singular vs plural in table/relation names.. :)

On Thu, Nov 5, 2015 at 3:48 PM, Jeff Smith <jeff.d.smith@xxxxxxxxxx <mailto:jeff.d.smith@xxxxxxxxxx>> wrote:

Leading commas are the best, but it quickly turns to a religious discussion…

*From:*Jack Applewhite [mailto:jack.applewhite@xxxxxxxxxxxxx <mailto:jack.applewhite@xxxxxxxxxxxxx>]
*Sent:* Thursday, November 05, 2015 10:47 AM
*To:* oracle-l


*Subject:* Re: What happened to SQL*Developer SQL Formatter?

Commas at the *beginning* of a line. YAY! A kindred spirit. That's the way I've set up my Formatter for a long time. Much more readable. My basic rules are

1. Make things (like column lists) vertical for easy scanning down, not around the bend.

2. Punctuation on the left.

Just about everything the Duhvelopers send me gets put through the SD Formatter. Only way I can decipher their code. I've converted a few of them, but most are unmoved.

Glad to see Jeff Smith's pointing out the Export option for the Formatter preferences. I'd missed that one.

----
Jack C. Applewhite - Database Administrator
Austin I.S.D. - MIS Department
512.414.9250 <tel:512.414.9250> (wk)

------------------------------------------------------------------------

*From:*oracle-l-bounce@xxxxxxxxxxxxx <mailto:oracle-l-bounce@xxxxxxxxxxxxx> <oracle-l-bounce@xxxxxxxxxxxxx <mailto:oracle-l-bounce@xxxxxxxxxxxxx>> on behalf of Niall Litchfield <niall.litchfield@xxxxxxxxx <mailto:niall.litchfield@xxxxxxxxx>>
*Sent:* Thursday, November 5, 2015 5:00 AM
*To:* jt2354@xxxxxxxxx <mailto:jt2354@xxxxxxxxx>
*Cc:* Maris Elsins; gogala.mladen@xxxxxxxxx <mailto:gogala.mladen@xxxxxxxxx>; oracle-l
*Subject:* Re: What happened to SQL*Developer SQL Formatter?

I took your sql and ran the formatter with my preferences (commas at the *beginning *of a line baby!!) and got the text below. That looks pretty reasonable to me. I know Jeff Smith reads this group so possibly he'll know if its possible to export/share preferences. If it isn't seems like a cool enhancement request to enforce corporate coding styles if nothing else.

SELECT

end_time

, wait_class#

, (time_waited_fg)/(intsize_csec/100)

, ( time_waited) /(intsize_csec/100)

, 0

FROM

v$waitclassmetric

UNION ALL

SELECT

end_time

, -1

, SUM(

CASE

WHEN metric_name = 'CPU Usage Per Sec'

THEN value

ELSE 0

END) fg

, SUM(

CASE

WHEN metric_name = 'Background CPU Usage Per Sec'

THEN value

ELSE 0

END) bg

, SUM(

CASE

WHEN metric_name = 'Average Active Sessions'

THEN value

ELSE 0

END) dbt

FROM

v$sysmetric

WHERE

group_id = 2

AND metric_name IN ('Background CPU Usage Per Sec', 'CPU Usage Per Sec', 'Average Active Sessions')

GROUP BY

end_time

ORDER BY

end_time

, wait_class#

On Thu, Nov 5, 2015 at 9:21 AM, John Thomas <jt2354@xxxxxxxxx <mailto:jt2354@xxxxxxxxx>> wrote:

Doesn't work well though.

trailing / left hanging and long lines in SELECT or WHERE clause are not broken up so they are readable.

I like the plain and simple

FUNCTION

(

FUNC2

(

column_name

)

)

... but have found no way of configuring SQL Dev formatter to do this. For example, the CASE statements are OK, but what happened with the functions on the SELECT list?

SELECT end_time, wait_class#, (time_waited_fg)/(intsize_csec/100), (

time_waited) /(intsize_csec/100), 0

FROM v$waitclassmetric

UNION ALL

SELECT end_time, -1, SUM(

CASE

WHEN metric_name = 'CPU Usage Per Sec'

THEN value

ELSE 0

END) fg, SUM(

CASE

WHEN metric_name = 'Background CPU Usage Per Sec'

THEN value

ELSE 0

END) bg, SUM(

CASE

WHEN metric_name = 'Average Active Sessions'

THEN value

ELSE 0

END) dbt

FROM v$sysmetric

WHERE group_id = 2

AND metric_name IN ('Background CPU Usage Per Sec', 'CPU Usage Per Sec',

'Average Active Sessions')

GROUP BY end_time

ORDER BY end_time, wait_class# /

Regards

John

On Thu, 5 Nov 2015 at 07:08 Maris Elsins <elmaris@xxxxxxxxx <mailto:elmaris@xxxxxxxxx>> wrote:

Hi,

It' s still there in SQL Developer 4.x, you can find it by
right-clicking the SQL text in the SQL sheet or hitting Ctrl+F7.


---

Maris Elsins

@MarisElsins <https://twitter.com/MarisElsins>

www.facebook.com/maris.elsins <https://www.facebook.com/maris.elsins>

On Thu, Nov 5, 2015 at 7:56 AM, Mladen Gogala
<gogala.mladen@xxxxxxxxx <mailto:gogala.mladen@xxxxxxxxx>> wrote:

In version 3.x, there was a SQL Formatter in the "Edit" menu. One
keystroke would reformat horribly tangled SQL monsters. In the
version 4.x, this very useful feature is gone. Why was that done?
Who decided to throw this out and why?
Regards

-- Mladen Gogala
Oracle DBA
http://mgogala.freehostia.com

--
//www.freelists.org/webpage/oracle-l



--

Niall Litchfield
Oracle DBA
http://www.orawin.info

Confidentiality Notice: This email message, including all attachments, is for the sole use of the intended recipient(s) and may contain confidential student and/or employee information. Unauthorized use of disclosure is prohibited under the federal Family Educational Rights & Privacy Act (20 U.S.C. §1232g, 34 CFR Part 99, 19 TAC 247.2, Gov’t Code 552.023, Educ. Code 21.355, 29 CFR 1630.14(b)(c)). If you are not the intended recipient, you may not use, disclose, copy or disseminate this information. Please call the sender immediately or reply by email and destroy all copies of the original message, including attachments.



--

Niall Litchfield
Oracle DBA
http://www.orawin.info

**** This communication may contain privileged and/or confidential information. If you are not the intended recipient, you are hereby notified that disclosing, copying, or distributing of the contents is strictly prohibited. If you have received this message in error, please contact the sender immediately and destroy any copies of this document. ****



--




Other related posts: