It can be necessary to change the data type of a particular value. For example, a numeric or date value might be stored as a string from a CSV file.
In our first example, we convert a string literal to an integer:
1 SQL> select TypeNameOf(’42’), ’42’, TypeNameOf(ToInteger(’42’)), ToInteger(’42’) from Empty(rows=10);
NOTE: Our example statement also used the TypeNameOf() and Empty(rows=n) functions, which we used to output a value’s data type and generate some dummy rows.
In our next example, we convert a string to a date:
1 SQL> select TypeNameOf(’04/1/1972′), ’04/1/1972′, TypeNameOf(ToDate(’04/1/1972′,‘M/d/yyyy’)), ToDate(’04/1/1972′,‘M/d/yyyy’) from Empty(rows=5);