CAST examples : Cast « Conversion Functions « Oracle PL/SQL Tutorial






SQL>
SQL> DECLARE
  2     a TIMESTAMP WITH TIME ZONE;
  3     b VARCHAR2(40);
  4     c TIMESTAMP WITH LOCAL TIME ZONE;
  5  BEGIN
  6     a := CAST ('24-Feb-2002 09.00.00.00 PM US/Eastern' AS TIMESTAMP WITH TIME ZONE);
  7     b := CAST (a AS VARCHAR2);
  8     c := CAST (a AS TIMESTAMP WITH LOCAL TIME ZONE);
  9
 10     DBMS_OUTPUT.PUT_LINE(a);
 11     DBMS_OUTPUT.PUT_LINE(b);
 12     DBMS_OUTPUT.PUT_LINE(c);
 13  END;
 14  /

PL/SQL procedure successfully completed.

SQL>
SQL>
SQL>








15.10.Cast
15.10.1.cast(12.98 as number(2)) example1
15.10.2.select cast('oak' as char(10) ) example2
15.10.3.select cast(null as date ) example3
15.10.4.Cast string to date type before comparison
15.10.5.Cast null as timestamp
15.10.6.Cast table of numbers
15.10.7.Cast number to a char
15.10.8.Cast date to char
15.10.9.Cast decimal to integer
15.10.10.Cast varchar to char
15.10.11.CAST examples
15.10.12.Use Date to cast string to date type