Creating a VARRAY Type in an Oracle Database - Java JDBC

Java examples for JDBC:Oracle

Description

Creating a VARRAY Type in an Oracle Database

Demo Code

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class Main {

  public void m() {
    try {/*from  w  w  w.j av  a  2 s.c  o m*/
      Connection connection = null;
      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 Tutorials