Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 2nd, 2005, 11:51 AM
dante2010 dante2010 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2002
Posts: 599 dante2010 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 3 h 46 m 49 sec
Reputation Power: 7
Help with to_number

Hi,

I am trying to use to_number to make sure the number I am passing to Oracle is of the correct precision.

The problem I'm having is that Oracle seems to view a value of 4.50 as 45.00. My SQL statement is:

INSERT INTO
ETECDBA.IVR_COMMANDTABLE
(
RECORDKEY,
AGENCYDESIGNATOR,
PAYMENTAMOUNT,
CREDITORDEBITCARDTYPE,
CREDITORDEBITCARDNUMBER,
CREDITORDEBITCARDEXPIRYDATE,
CREDITORDEBITCARDAUTHNUM,
VENDORID,
VENDORTRANSACTIONNUMBER,
COMMANDNUMBER
) VALUES (
$recordKey,
'$agency',
to_number ($amountDue, '999.99'),
'$strCCType',
'$strChoppedCCNum',
'$strExpiryDate',
'$authNum',
'$vendorID',
$refNum,
$command)

.. where $amountDue is 4.50 .

Any reason why Oracle would see it as 45.00?

Reply With Quote
  #2  
Old July 4th, 2005, 01:33 AM
Ach Ach is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 46 Ach User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 36 m 29 sec
Reputation Power: 4
What is the datatype of PAYMENTAMOUNT column?

Reply With Quote
  #3  
Old July 5th, 2005, 07:54 AM
dante2010 dante2010 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2002
Posts: 599 dante2010 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 3 h 46 m 49 sec
Reputation Power: 7
Number(15,2)

Reply With Quote
  #4  
Old July 5th, 2005, 10:48 AM
jim mcnamara jim mcnamara is offline
......@.........
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,308 jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 5 h 17 m 10 sec
Reputation Power: 48
This looks like a command line insert - maybe from a here doc -- in unix.
if you echo $amountDue what EXACTLY does it show?

Reply With Quote
  #5  
Old July 5th, 2005, 11:14 AM
shammat shammat is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 1,005 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 11 h 53 m 24 sec
Reputation Power: 67
Quote:
Originally Posted by dante2010
I am trying to use to_number to make sure the number I am passing to Oracle is of the correct precision.

What's wrong with using round() to ensure the proper number of decimals?

Thomas

Reply With Quote
  #6  
Old July 7th, 2005, 05:37 PM
dante2010 dante2010 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2002
Posts: 599 dante2010 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 3 h 46 m 49 sec
Reputation Power: 7
So upon further testing it appears that the to_number() works correctly when you don't pass it a variable. IE:

to_number ('4.50', '999.99')

... but when used with a variable, it updates with the wrong amount.

to_number ($amountDue, '999.99')

In this case, echoing $amountDue displays 4.50.

Reply With Quote
  #7  
Old July 14th, 2005, 06:06 AM
xpi0t0s xpi0t0s is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 19 xpi0t0s User rank is Private First Class (20 - 50 Reputation Level)xpi0t0s User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 13 m 51 sec
Reputation Power: 0
You can check the contents of amountDue with the FX specifier; this will print today's date if it contains exactly '4.50', or an error if it doesn't:

select to_date($amountDue,'FX"4.50"') from dual;

Alternatively select dump('4.50') from dual; should print
Typ=96 Len=4: 52,46,53,48

so select dump($amountDue) from dual should print the same if it contains exactly '4.50'.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Help with to_number


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT