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

Oracle PL/SQL Tutorial
1. Introduction
2. Query Select
3. Set
4. Insert Update Delete
5. Sequences
6. Table
7. Table Joins
8. View
9. Index
10. SQL Data Types
11. Character String Functions
12. Aggregate Functions
13. Date Timestamp Functions
14. Numerical Math Functions
15. Conversion Functions
16. Analytical Functions
17. Miscellaneous Functions
18. Regular Expressions Functions
19. Statistical Functions
20. Linear Regression Functions
21. PL SQL Data Types
22. PL SQL Statements
23. PL SQL Operators
24. PL SQL Programming
25. Cursor
26. Collections
27. Function Procedure Packages
28. Trigger
29. SQL PLUS Session Environment
30. System Tables Data Dictionary
31. System Packages
32. Object Oriented
33. XML
34. Large Objects
35. Transaction
36. User Privilege
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Oracle PL/SQL Tutorial » Conversion Functions » Cast 
15. 10. 6. Cast table of numbers
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

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
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.