Data implicit conversion examples: from char to number : Data Type Convert « PL SQL « Oracle PL / SQL






Data implicit conversion examples: from char to number

SQL>
SQL> -- Implicit conversion examples.
SQL>
SQL> SET SERVEROUTPUT ON
SQL>
SQL> DECLARE
  2     n1    NUMBER;
  3     cn1   VARCHAR2(10);
  4     cn2   VARCHAR2(10);
  5  BEGIN
  6     -- Repeat the same example as above, but with numbers.
  7     cn1 := '995';
  8     n1 := cn1 + .99 ;
  9     cn2 := n1;
 10     DBMS_OUTPUT.PUT_LINE('CN1 = ' || cn1);
 11     DBMS_OUTPUT.PUT_LINE('CN2 = ' || cn2);
 12  END;
 13  /
CN1 = 995
CN2 = 995.99

PL/SQL procedure successfully completed.

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.Convert char to number and number to char with various formats
8.Data implicit conversion examples: from char to date
9.Expressing your work in scientific notation with TO_CHAR()