Cast table of numbers : Cast « Conversion Functions « Oracle PL/SQL Tutorial






SQL> create table num_tab (col1 number(10));

Table created.

SQL>
SQL>
SQL>
SQL> CREATE OR REPLACE TYPE numberTableType AS TABLE OF NUMBER(10);
  2  /

Type created.

SQL>
SQL> CREATE TABLE address_list (list_id VARCHAR2(6)PRIMARY KEY,
  2                   home_addresses numberTableType )
  3                   NESTED TABLE home_addresses STORE AS home_addreses_tab;



SQL>
SQL>
SQL> INSERT INTO address_list VALUES ('H101',numberTableType(1001,1002,1003,1004));



SQL>
SQL>
SQL>
SQL> declare
  2    v_numberVarryType numberTableType := numberTableType(NULL,NULL,NULL);
  3  begin
  4    v_numberVarryType(1):=1001;
  5    v_numberVarryType(2):=1002;
  6    v_numberVarryType(3):=1003;
  7    insert into num_tab select column_value from TABLE(CAST(v_numberVarryType AS numberTableType));
  8  end;
  9  /

PL/SQL procedure successfully completed.

SQL>
SQL> select * from num_tab;

  COL1
------
  1001
  1002
  1003

3 rows selected.

SQL>
SQL>
SQL> drop table num_tab;

Table dropped.

SQL>
SQL> drop table address_list;



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