Getting a VARRAY Value from an Oracle Table

This example retrieves values contained in an Oracle VARRAY type. The example uses the table and array type created in Creating a VARRAY Type in an Oracle Database.
try { // Create a statement Statement stmt = connection.createStatement(); // Select rows from varray_table ResultSet resultSet = stmt.executeQuery("SELECT * FROM varray_table"); // Get the VARRAY values from each row while (resultSet.next()) { // Get the VARRAY value in the first column oracle.sql.ARRAY array = ((oracle.jdbc.driver.OracleResultSet)resultSet).getARRAY(1); // Get the VARRAY elements; values.length is the number of values in the VARRAY java.math.BigDecimal[] values = (java.math.BigDecimal[])array.getArray(); } } catch (SQLException e) { }

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.