Skip to Main Content

SQL Developer

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

SQL Developer 19.2.1 - Custom format: line break on hints, columns/argument alignment

Dilly1990Jan 16 2020 — edited Apr 19 2020

We are migrating from Toad to Sql developer and below are few requirement to format the code on the Sql developer.

All the code snippets show below are from PL/Sql.

  1. Line break after the hint on the Select

SELECT /*+ use_hash(rtd st incl str) */ rtd.str_no AS str_no

,TRUNC (rtd.tx_dte_tme) AS tx_dte

,NVL (st.trml_typ_cd,’UNK’) AS trml_typ_cd

Expected:

SELECT /*+ use_hash(rtd st incl str) */

rtd.str_no AS str_no

,TRUNC ( rtd.tx_dte_tme) AS tx_dte

,NVL (st.trml_typ_cd, ‘UNK’) AS trml_typ_cd

  1. Extra line break before Cursor declaration only when variable/constant defined above.

c_defaultBsStrNo CONSTANT STORE.str_no%TYPE := 0;

CURSOR l_rtlTndrDtlCur IS

SELECT * from dual

Expected:

c_defaultBsStrNo CONSTANT STORE.str_no%TYPE := 0;

CURSOR l_rtlTndrDtlCur IS

SELECT * from dual

  1. Remove line beak on Procedure / Function / Cursor parameter declaration. Line break are need only when the declaration exceeds MAX CHAR LINE WIDTH

PROCEDURE insTndrOnly (

p_runDte IN DATE

,p_txDte IN DATE

);

Expected :

PROCEDURE insTndrOnly (p_runDte IN DATE, p_txDte IN DATE);

  1. When invoking the procedure, line breaksBeforeComma on each parameter and also parenthesis need to be aligned

pastedImage_11.png

Expected:

pastedImage_12.png

  1. if_stmt – Line break before on the and_expr.

IF (l_prevStrNo = l_tndrCrctnChgRec.str_no) AND (l_prevTrmlNo = l_tndrCrctnChgRec.trml_no) AND (l_prevTxNo = l_tndrCrctnChgRec.tx_no) AND (l_prevTxDte = l_tndrCrctnChgRec.tx_dte) AND (l_prevTrmlTypCd = l_tndrCrctnChgRec.trml_typ_cd) AND (l_prevRunDTe = l_tndrCrctnChgRec.run_dte)

THEN l_prevTndrActnCd = 0;

ELSE l_prevTndrActnCd = 1;

END IF;

Expected:

pastedImage_16.png

Below are the changes made to the Advanced format:

pastedImage_20.png

I would really appreciate, if you could help me out.

Comments

807607
An int value is a 32-bit number, and that's the largest value that can be represented in 32-bit two's complement.

Binary numeral system (Wikipedia)
Two's complement (Wikipedia)
Cat and Mouse Games with Bits

If you still have trouble understanding after reading the links, please ask, but the links contain the full, detailed explanation you need.

~
807607
Can someone provide me with a detailed explanation of
why 2,147,483,647 is the maximum integer value in
Java?

I'm writing a report and need to know and i can't
find an explanation anywhere.

Thanks a lot
Because that's how high Java can count using 32 toes and fingers.
masijade
Can someone provide me with a detailed explanation
of
why 2,147,483,647 is the maximum integer value in
Java?

I'm writing a report and need to know and i can't
find an explanation anywhere.

Thanks a lot
Because that's how high Java can count using 32 toes
and fingers.
Really? I only have 21. Wait a minute! That's neither a toe nor a finger!
807607
Ok I read through the material and Im still a little confused, although I think I get the gist.

This what i've come up with,
The integer values in Java are 32-bit Two's complement encoded
numbers and the highest possible value for this system is
2,147,483,647. The value 2,147,483,648 or 2n-1 where n is 32 is
negated under two's complement representation and becomes the
-2n-1s place. It is the most significant bit, meaning it has the
greatest value. In Two's compliment the most significant bit is
becomes the "sign bit" and indicates the sign of the number. If the
sign bit is 0 then largest number that can be stored in the remaing
31 bits is (2n-1-1) or 232-1-1 = 231-1 = 2,147,483,648 -1 =
2,147,483,647.
JosAH

Ok I read through the material and Im still a little
confused, although I think I get the gist.

[ snip ]

Yep, you got it alright. Suppose there were only three bits in a word.
The following table would describe it all then:

binary unsigned 2s-complement 1s-complement
-------------------------------------------
000    0         0             0
001    1         1             1
010    2         2             2
011    3         3             3
100    4        -4            -3
101    5        -3            -2
110    6        -2            -1
111    7        -1            -0

You can forget all about the last column if you like.

kind regards,

Jos

796440
What in particular are you still confused about?

Your explanation looks pretty much correct. Note that the high-order bit isn't strictly a "sign bit." What I mean is, if it were "strictly a sign bit," then -1 would be the same as+1 with a one in the first bit. -1 would be 0x10000001. But that's not that case. (I think that's one's comlement, actually).

-1 = 0xFFFFFFFF
-2 = 0xFFFFFFFE
most negative number = 0x10000000
most positive number = 0x7FFFFFFF

Note that if you subtract one from the most negatie number, you wrap around to the most positive, and if you add one to -1, you get 0 (ignoring any carry/borrow).
807607
...if it were "strictly a sign bit," then -1
would be the same as+1 with a one in the first bit.
-1 would be 0x10000001. But that's not that case. (I
think that's one's comlement, actually).
One's complement is simply the inverse of the positive number. A representation with a pure sign bit is... well, just a sign bit... no "complement" of any sort.
796440
...if it were "strictly a sign bit," then -1
would be the same as+1 with a one in the first
bit.
-1 would be 0x10000001. But that's not that case.
(I
think that's one's comlement, actually).
One's complement is simply the inverse of the
positive number.
Ah, yes. I knew that didn't sound right. Thanks for setting me straight.
1 - 8

Post Details

Added on Jan 16 2020
10 comments
3,727 views