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