Convert char to number : Data Type Convert « PL SQL « Oracle PL / SQL

Home
Oracle PL / SQL
1.Aggregate Functions
2.Analytical Functions
3.Char Functions
4.Constraints
5.Conversion Functions
6.Cursor
7.Data Type
8.Date Timezone
9.Hierarchical Query
10.Index
11.Insert Delete Update
12.Large Objects
13.Numeric Math Functions
14.Object Oriented Database
15.PL SQL
16.Regular Expressions
17.Report Column Page
18.Result Set
19.Select Query
20.Sequence
21.SQL Plus
22.Stored Procedure Function
23.Subquery
24.System Packages
25.System Tables Views
26.Table
27.Table Joins
28.Trigger
29.User Previliege
30.View
31.XML
Oracle PL / SQL » PL SQL » Data Type Convert 
Convert char to number

SQL>
SQL> DECLARE
  2        myChar VARCHAR2(20:= '$119,252.75';
  3        myNumber NUMBER ;
  4  BEGIN
  5        myNumber := TO_Number(myChar,'$999,999.99');
  6        DBMS_OUTPUT.PUT_LINE('The converted number is: ' || myNumber);
  7        DBMS_OUTPUT.PUT_LINE('Your commission at 6% is: ' |(myNumber*.06));
  8  END;
  9  /
The converted number is: 119252.75
Your commission at 6% is: 7155.165

PL/SQL procedure successfully completed.

SQL>

           
       
Related examples in the same category
1.Convert char to date: TO_DATE('January 01, 2000','Month DD, YYYY')
2.Convert number to char
3.Converting number to character formatted as a numeric string
4.Converting VARCHAR2 percentage data to a decimal equivalent
5.Convert date to char, and char to date with various formats
6.Convert char to number and number to char with various formats
7.Data implicit conversion examples: from char to number
8.Data implicit conversion examples: from char to date
9.Expressing your work in scientific notation with TO_CHAR()
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.