The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.sql  [73 examples] > Oracle VARRAYs  [4 examples]

e301. Creating a VARRAY Type in an Oracle Database

A VARRAY is a variable-length ordered list of values of one type. This example creates a VARRAY that can hold up to ten NUMBER values.
    try {
        Statement stmt = connection.createStatement();
    
        // Create a 10-element VARRAY of NUMBERs
        stmt.execute("CREATE TYPE number_varray AS VARRAY(10) OF NUMBER(12, 2)");
    
        // Create a table with a column to hold the new VARRAY type
        stmt.execute("CREATE TABLE VARRAY_TABLE(col_number_array number_varray)");
    } catch (SQLException e) {
    }

 Related Examples
e302. Inserting a VARRAY Value into an Oracle Table
e303. Inserting a VARRAY Value into an Oracle Table Using a Prepared Statement
e304. Getting a VARRAY Value from an Oracle Table

See also: Batching    Connections    Database Meta Data    Deleting Data    Drivers    Importing and Exporting    Inserting and Updating Data    Oracle OBJECTs    Procedures and Functions    Retrieving Data    Scrollable Result Sets    Tables    Updatable Result Sets   


© 2002 Addison-Wesley.