Convert char to number and number to char with various formats : Data Type Convert « PL SQL « Oracle PL / SQL






Convert char to number and number to char with various formats

SQL>
SQL> -- Examples of the conversion functions.
SQL> SET SERVEROUTPUT ON
SQL>
SQL> DECLARE
  2     n1    NUMBER;
  3     n2    NUMBER;
  4     n3    NUMBER;
  5  BEGIN
  6     -- here are some examples of numeric conversions.
  7     n1 := TO_NUMBER ('123.99','999D99');
  8     n2 := TO_NUMBER ('$1,235.95','$9G999D99');
  9     DBMS_OUTPUT.PUT_LINE('n1 = ' || TO_CHAR(n1,'999D99'));
 10     DBMS_OUTPUT.PUT_LINE('n2 = ' || TO_CHAR(n2,'$9G999D99'));
 11  END;
 12  /
n1 =  123.99
n2 =  $1,235.95

PL/SQL procedure successfully completed.

SQL>
SQL>
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.Convert char to number
5.Converting VARCHAR2 percentage data to a decimal equivalent
6.Convert date to char, and char to date 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()