Converting a character formatted as currency to an integer value : Number to Char « PL SQL « Oracle PL / SQL






Converting a character formatted as currency to an integer value


SQL>
SQL>
SQL> -- Converting a character formatted as currency to an integer value.
SQL> DECLARE
  2        myString VARCHAR2(20) := '$123,456.78';
  3        myNumber NUMBER ;
  4  BEGIN
  5        myNumber := TO_Number(myString,'$999,999,999.99');
  6        DBMS_OUTPUT.PUT_LINE('The converted number is: ' || myString);
  7        DBMS_OUTPUT.PUT_LINE('Your commission at 6% is: ' || (myNumber*.06));
  8  END;
  9  /
The converted number is: $123,456.78
Your commission at 6% is: 7407.4068

PL/SQL procedure successfully completed.

SQL>
SQL>


           
       








Related examples in the same category

1.Converting Numbers to Characters Formatted as a Numeric String
2.Expressing Your Work in Scientific Notation
3.Illegal conversion between character and number