943,724 Members | Top Members by Rank

Ad:
  • Oracle Discussion Thread
  • Unsolved
  • Views: 2224
  • Oracle RSS
Nov 13th, 2008
0

Subtracting a negative value

Expand Post »
Does anyone know how Oracle's PL/SQL handles subtraction with a negative number? Really what I need to know is, given the following: (NOTE: this is NOT the code I'm working with. It's just an example to give and idea of what I'm trying to do.)
Oracle Syntax (Toggle Plain Text)
  1. DECLARE
  2. number1 NUMBER;
  3. number2 NUMBER;
  4. number3 NUMBER;
  5. BEGIN
  6. number1 := 5;
  7. number2 := -2;
  8. number3 := number1 - number2;
  9. END;
  10. /

How do I get number3 to be 7, like math is supposed to work (5 - (-2) = 7)? I keep getting 3. Anyone?
Similar Threads
Reputation Points: 11
Solved Threads: 0
Light Poster
bondo is offline Offline
43 posts
since Apr 2007
Nov 13th, 2008
0

Re: Subtracting a negative value

but i am getting 7, how come you are getting 3 ?

oracle Syntax (Toggle Plain Text)
  1. DECLARE
  2. number1 NUMBER;
  3. number2 NUMBER;
  4. number3 NUMBER;
  5. BEGIN
  6. number1 := 5;
  7. number2 := -2;
  8. number3 := number1 - number2;
  9. dbms_output.put_line(number3);
  10. END;
Featured Poster
Reputation Points: 665
Solved Threads: 427
Posting Genius
debasisdas is offline Offline
6,406 posts
since Feb 2007
Nov 13th, 2008
0

Re: Subtracting a negative value

That was my question. Why am I getting 3?
Reputation Points: 11
Solved Threads: 0
Light Poster
bondo is offline Offline
43 posts
since Apr 2007
Nov 15th, 2008
0

Re: Subtracting a negative value

the same block of pl/sql code never gives different output to different people on different machine.
Featured Poster
Reputation Points: 665
Solved Threads: 427
Posting Genius
debasisdas is offline Offline
6,406 posts
since Feb 2007
Dec 9th, 2008
0

Re: Subtracting a negative value

Hai Bondo,
you will never get 3 for the above code..please check it once again...........................
Reputation Points: 10
Solved Threads: 0
Newbie Poster
like_to_learn is offline Offline
9 posts
since Dec 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Oracle Forum Timeline: Oracle SQL Plus Joining
Next Thread in Oracle Forum Timeline: Deletion of Autonumber





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC