/*
drop table varray_table;
drop type num_varray;
CREATE TYPE num_varray AS VARRAY() OF VARCHAR()
/
CREATE TABLE varray_table (col num_varray);
INSERT INTO varray_table VALUES (num_varray(你好 abc));
select * from varray_table;
*/
import javasql*;
import javamath*;
import oraclejdbcdriver*;
import oraclesql*;
class Array
{
public static void main(String args[]) throws Exception
{
int oracleId = CharacterSetZHSGBK_CHARSET;
CharacterSet dbCharset = CharacterSetmake(oracleId);
DriverManagerregisterDriver
(new oraclejdbcdriverOracleDriver());
Connection conn =
DriverManagergetConnection
(jdbc:oracle:thin:@::db
mytest
mytest);
Statement stmt = conncreateStatement();
ResultSet rs = stmtexecuteQuery(SELECT * FROM varray_table);
while (rsnext()) {
ARRAY my_array = ((OracleResultSet)rs)getARRAY();
// return the SQL type names integer codes
// and lengths of the columns
Systemoutprintln (Array is of type + my_arraygetSQLTypeName());
Systemoutprintln (Array element is of typecode + my_arraygetBaseType());
Systemoutprintln (Array is of length + my_arraylength());
// get Array elements
String[] values = (String[]) my_arraygetArray();
for (int i = ; i < valueslength; i++)
{
oraclesqlCHAR out_value = new oraclesqlCHAR(values[i] dbCharset);
Systemoutprintln(>> index + i + = + out_value);
}
}
rsclose();
stmtclose();
connclose();
}
}