Converting VARCHAR2 percentage data to a decimal equivalent
SQL> -- Converting VARCHAR2 percentage data to a decimal equivalent.
SQL> DECLARE
2 myChar VARCHAR2(20) := '33.33';
3 myNumber NUMBER ;
4 BEGIN
5 myNumber := TO_Number(myChar,'999.999999');
6 DBMS_OUTPUT.PUT_LINE('The converted number is: ' || myNumber);
7 DBMS_OUTPUT.PUT_LINE('Your decimal equivalent is: ' || (myNumber/100));
8 END;
9 /
The converted number is: 33.33
Your decimal equivalent is: .3333
PL/SQL procedure successfully completed.
SQL>
SQL>
Related examples in the same category