Updated on 2025-04-14 GMT+08:00

Array

This section describes the differences between Oracle Database and GaussDB when the JDBC driver of the java.sql.Array type is used.

Table 1 Constructor reference

Constructor

Oracle Database

GaussDB

API Difference

1. Use the static constructor of ArrayDescriptor to construct an ArrayDescriptor object.

2. Use ArrayDescriptor to construct an array object.

String typeName = "XXX";

Connection conn = getConnection();

Object[] elements = null;

ArrayDescriptor desc = ArrayDescriptor.createDescriptor(typeName, conn);

Array array = new ARRAY(desc, conn, elements);

String typeName = "xxx";

Connection conn = getConnection();

Object[] elements = null;

ArrayDescriptor desc = ArrayDescriptor.getDescriptor(typeName, conn);

Array array = new GaussArray(desc, elements);

  • Different names of the static constructor for ArrayDescriptor: In Oracle Database, it is createDescriptor, while in GaussDB it is getDescriptor.
  • Different constructor names for arrays: In Oracle Database, it is ARRAY(ArrayDescriptor, Connection, Object), while in GaussDB, it is GaussArray(ArrayDescriptor, Object).
  • Variable description:

    typeName indicates the type name and is case-sensitive. Generally, it uses uppercase in Oracle Database, while in GaussDB it is lowercase.

    conn indicates the connection object for the corresponding database.

    elements indicates the element data of the corresponding type.

  1. GaussDB currently does not support the constructors not listed in the aforementioned table.
  2. If the element type is a character type and the length of the construction input string exceeds that defined by the element type, Oracle Database reports an error during input parameter binding.

    If the array type is the varray type and the number of elements exceeds the maximum length of varray, Oracle Database reports an error during input parameter binding.

    GaussDB does not verify type modifiers when constructing or binding input parameters. When a database receives array objects and executes SQL statements, it decides whether to report an error.

Table 2 API reference

Method

Return Value Type

Throws

GaussDB

getBaseTypeName()

String

SQLException

Supported.

getBaseType()

int

SQLException

Supported.

getArray()

Object

SQLException

Supported.

getArray(java.util.Map<String,Class<?>> map)

Object

SQLException

Not supported.

getArray(long index, int count)

Object

SQLException

Supported.

getArray(long index, int count, java.util.Map<String,Class<?>> map)

Object

SQLException

Not supported.

getResultSet()

ResultSet

SQLException

Not supported.

getResultSet(java.util.Map<String,Class<?>> map)

ResultSet

SQLException

Not supported.

getResultSet(long index, int count)

ResultSet

SQLException

Not supported.

getResultSet (long index, int count, java.util.Map<String,Class<?>> map)

ResultSet

SQLException

Not supported.

free()

void

SQLException

Not supported.

Table 3 Differences in the getArray() API

Element Database Type

Actual Return Value Type of the getArray API (Oracle Database)

Actual Return Value Type of the getArray API (GaussDB)

CHAR

java.lang.String[]

java.lang.String[]

VARCHAR/VARCHAR2

java.lang.String[]

java.lang.String[]

NCHAR

java.lang.String[]

java.lang.String[]

NVARCHAR2

java.lang.String[]

java.lang.String[]

NUMBER

java.math.BigDecimal[]

java.math.BigDecimal[]

NUMERIC

java.math.BigDecimal[]

java.math.BigDecimal[]

DECIMAL

java.math.BigDecimal[]

java.math.BigDecimal[]

INTEGER

java.math.BigDecimal[]

java.lang.Integer[]

SMALLINT

java.math.BigDecimal[]

java.lang.Short[]

DOUBLE PRECISION

java.math.BigDecimal[]

java.lang.Double[]

FLOAT

java.math.BigDecimal[]

java.lang.Double[]

REAL

java.math.BigDecimal[]

java.lang.Float[]

BINARY_DOUBLE

java.lang.Double[]

java.lang.Double[]

BINARY_INTEGER

java.math.BigDecimal[]

java.lang.Integer[]

BOOLEAN

java.math.BigDecimal[]

java.lang.Boolean[]

TIMESTAMP

java.sql.Timestamp[]

java.sql.Timestamp[]

TIMESTAMP WITH TIME ZONE

java.time.OffsetDateTime[]

java.sql.Timestamp[]

BLOB

oracle.sql.BLOB[]

java.sql.Blob[]

CLOB

oracle.sql.CLOB[]

java.sql.Clob[]

Set/Array

java.lang.Object[]

java.sql.Array[]

RECORD

java.lang.Object[]

java.sql.Struct[]

  1. GaussDB currently does not support the types unlisted in the aforementioned table.
  2. For details about the differences in the return values of the getArray(long index, int count) API, see the preceding table.
  3. The differences in index parameter of getArray(long index, int count) are as follows:
    • The value range supported by Oracle Database is [1, Long.MAX_VALUE]. GaussDB supports a range of [1, Integer.MAX_VALUE].
    • If the index value is greater than that of Integer.MAX_VALUE, it will be truncated in Oracle Database, while an error is reported in GaussDB.
Table 4 Differences in the getBaseType() API

Element Database Type

Return Value of the getBaseType API (Oracle Database)

Return Value of the getBaseType API (GaussDB)

CHAR

java.sql.Types.CHAR

java.sql.Types.CHAR

VARCHAR/VARCHAR2

java.sql.Types.VARCHAR

java.sql.Types.VARCHAR

NCHAR

java.sql.Types.NCHAR

java.sql.Types.CHAR

NVARCHAR2

java.sql.Types.NVARCHAR

java.sql.Types.VARCHAR

NUMBER

java.sql.Types.NUMERIC

java.sql.Types.NUMERIC

NUMERIC

java.sql.Types.DECIMAL

java.sql.Types.NUMERIC

DECIMAL

java.sql.Types.DECIMAL

java.sql.Types.NUMERIC

INTEGER

java.sql.Types.NUMERIC

java.sql.Types.INTEGER

SMALLINT

java.sql.Types.NUMERIC

java.sql.Types.SMALLINT

DOUBLE PRECISION

java.sql.Types.FLOAT

java.sql.Types.DOUBLE

FLOAT

java.sql.Types.FLOAT

java.sql.Types.DOUBLE

REAL

java.sql.Types.FLOAT

java.sql.Types.REAL

BINARY_DOUBLE

oracle.jdbc.OracleTypes.BINARY_DOUBLE

java.sql.Types.DOUBLE

BINARY_INTEGER

java.sql.Types.NUMERIC

java.sql.Types.INTEGER

BOOLEAN

java.sql.Types.NUMERIC

java.sql.Types.BIT

TIMESTAMP

java.sql.Types.TIMESTAMP

java.sql.Types.TIMESTAMP

TIMESTAMP WITH TIME ZONE

oracle.jdbc.OracleTypes.TIMESTAMPTZ

java.sql.Types.TIMESTAMP

BLOB

java.sql.Types.BLOB

java.sql.Types.BLOB

CLOB

java.sql.Types.CLOB

java.sql.Types.CLOB

Set/Array

java.sql.Types.ARRAY

java.sql.Types.ARRAY

RECORD

java.sql.Types.STRUCT

java.sql.Types.STRUCT

GaussDB currently does not support the types unlisted in the aforementioned table.

Table 5 Differences in the getBaseTypeName() API

Element Database Type

Return Value of the getBaseTypeName API (Oracle Database)

Return Value of the getBaseTypeName API (GaussDB)

CHAR

"CHAR"

"bpchar"

VARCHAR/VARCHAR2

"VARCHAR"

"varchar"

NCHAR

"NCHAR"

"bpchar"

NVARCHAR2

"NVARCHAR"

"nvarchar2"

NUMBER

"NUMBER"

"numeric"

NUMERIC

"DECIMAL"

"numeric"

DECIMAL

"DECIMAL"

"numeric"

INTEGER

"NUMBER"

"int4"

SMALLINT

"NUMBER"

"int2"

DOUBLE PRECISION

"FLOAT"

"float8"

FLOAT

"FLOAT"

"float8"

REAL

"FLOAT"

"float4"

BINARY_DOUBLE

"BINARY_DOUBLE"

"float8"

BINARY_INTEGER

"NUMBER"

"int4"

BOOLEAN

"NUMBER"

"bool"

TIMESTAMP

"TIMESTAMP"

"timestamp"

TIMESTAMP WITH TIME ZONE

"TIMESTAMP WITH TIME ZONE"

"timestamptz"

BLOB

"BLOB"

"blob"

CLOB

"CLOB"

"clob"

Set/Array

See the description below.

See the description below.

RECORD

See the description below.

See the description below.

  1. GaussDB currently does not support the types unlisted in the aforementioned table.
  2. When an element is of the set, array, or RECORD type that is defined within a package, the return rules for getBaseTypeName are as follows:
    • OJDBC11 returns schemaName.packageName.typeName.
    • OJDBC8 generally returns schemaName.packageName.typeName, or returns "schemaName"."packageName.typeName" in the following condition:

      Any of schemaName, packageName, or typeName does not meet the rule of starting with a letter followed by characters including letters, digits, or underscores.

    • GaussDB generally returns schemaName.packageName.typeName, or returns "schemaName"."packageName"."typeName" in the following condition:

      Any of schemaName, packageName, or typeName does not meet the rule of starting with a letter or underscore followed by characters including letters, digits, or underscores.

  3. When an element is of the set, array, or RECORD type that is defined in the schema (but not in the package), the return rules for getBaseTypeName are as follows:
    • OJDBC11 returns schemaName.typeName.
    • OJDBC8 generally returns schemaName.typeName, or returns "schemaName"."typeName" in the following condition:

      Any of schemaName or typeName does not meet the rule of starting with a letter followed by characters including letters, digits, or underscores.

    • GaussDB generally returns schemaName.typeName, or returns "schemaName"."typeName" in the following condition:

      Any of schemaName or typeName does not meet the rule of starting with a letter or underscore followed by characters including letters, digits, or underscores.

  4. If no special processing is performed during element type creation, the getBaseTypeName API typically returns the type name in uppercase in Oracle Database, while returns the type name in lowercase in GaussDB.
Table 6 Differences in array construction APIs

Element Database Type

List of Java Types Supported by Element Input Parameters (Oracle Database OJDBC8)

List of Java Types Supported by Element Input Parameters (GaussDB)

Difference

CHAR

Any Java type

Byte, Short, Integer, Long, BigInteger, BigDecimal, Float, Double, Character, Boolean, java.sql.Date, java.sql.Time, java.sql.Timestamp, and PGClob

The different types supported by element input parameters can be seen in the table.

VARCHAR/VARCHAR2

Any Java type

Byte, Short, Integer, Long, BigInteger, BigDecimal, Float, Double, Character, Boolean, java.sql.Date, java.sql.Time, java.sql.Timestamp, and PGClob

The different types supported by element input parameters can be seen in the table.

NCHAR

Any Java type

Byte, Short, Integer, Long, BigInteger, BigDecimal, Float, Double, Character, Boolean, java.sql.Date, java.sql.Time, java.sql.Timestamp, and PGClob

The different types supported by element input parameters can be seen in the table.

NVARCHAR2

Any Java type

Byte, Short, Integer, Long, BigInteger, BigDecimal, Float, Double, Character, Boolean, java.sql.Date, java.sql.Time, java.sql.Timestamp, and PGClob

The different types supported by element input parameters can be seen in the table.

NUMBER

Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, String, and oracle.sql.NUMBER

Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, and String

  1. The different types supported by element input parameters can be seen in the table.
  2. When the input parameter is of the Float, Double, BigDecimal, or String type and the decimal part is 0, Oracle Database truncates the decimal part, while GaussDB retains it.

NUMERIC

Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, String, and oracle.sql.NUMBER

Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, and String

  1. The different types supported by element input parameters can be seen in the table.
  2. When the input parameter is of the Float, Double, BigDecimal, or String type and the decimal part is 0, Oracle Database truncates the decimal part, while GaussDB retains it.

DECIMAL

Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, String, and oracle.sql.NUMBER

Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, and String

  1. The different types supported by element input parameters can be seen in the table.
  2. When the input parameter is of the Float, Double, BigDecimal, or String type and the decimal part is 0, Oracle Database truncates the decimal part, while GaussDB retains it.

INTEGER

Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, String, and oracle.sql.NUMBER

Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, and String

  1. The different types supported by element input parameters can be seen in the table.
  2. The target types are inconsistent. For details, see differences in the getArray() API.
  3. When the input parameter value exceeds the integer range, GaussDB reports an error.

SMALLINT

Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, String, and oracle.sql.NUMBER

Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, and String

  1. The different types supported by element input parameters can be seen in the table.
  2. The target types are inconsistent. For details, see differences in the getArray() API.
  3. When the input parameter exceeds the Short range, GaussDB reports an error.

DOUBLE PRECISION

Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, String, and oracle.sql.NUMBER

Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, and String

  1. The different types supported by element input parameters can be seen in the table.
  2. The target types are inconsistent. For details, see differences in the getArray() API.
  3. Converting a higher-precision type to Double may result in precision loss.

FLOAT

Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, String, and oracle.sql.NUMBER

Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, and String

  1. The different types supported by element input parameters can be seen in the table.
  2. The target types are inconsistent. For details, see differences in the getArray() API.
  3. Converting a higher-precision type to Double may result in precision loss.

REAL

Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, String, and oracle.sql.NUMBER

Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, and String

  1. The different types supported by element input parameters can be seen in the table.
  2. The target types are inconsistent. For details, see differences in the getArray() API.
  3. Converting a higher-precision type to Float may result in precision loss.

BINARY_DOUBLE

Double and oracle.sql.BINARY_DOUBLE

Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, and String

  1. The different types supported by element input parameters can be seen in the table.
  2. The target types are inconsistent. For details, see differences in the getArray() API.
  3. Converting a higher-precision type to Double may result in precision loss.

BINARY_INTEGER

Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, AtomicInteger, AutomicLong, DoubleAccumulator, DoubleAddr, LongAccumulator, LondAdder, Striped64, String, and oracle.sql.NUMBER

Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, and String

  1. The different types supported by element input parameters can be seen in the table.
  2. The input parameters of the OJDBC11 element support the following types: Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, String, and oracle.sql.NUMBER.
  3. The target types are inconsistent. For details, see differences in the getArray() API.
  4. When the input value exceeds the Integer range, GaussDB reports an error.

    Oracle Database OJDBC8 performs data truncation.

BOOLEAN

Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, AtomicInteger, AutomicLong, DoubleAccumulator, DoubleAddr, LongAccumulator, LondAdder, Striped64, String, and oracle.sql.NUMBER

Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, and String

  1. The different types supported by element input parameters can be seen in the table.
  2. The input parameters of the OJDBC8 element support the following types: Byte, Short, Integer, Long, Float, Double, Boolean, BigDecimal, BigInteger, String, and oracle.sql.NUMBER.
  3. The target types are inconsistent. For details, see differences in the getArray() API.
  4. In GaussDB, the target data type is Boolean, which only supports inputs of 1, 0, "true", and "false".

TIMESTAMP

byte[], java.sql.Date, Calendar, java.util.Date, LocalDate, LocalDateTime, LocalTime, OffsetDateTime, OffsetTime, String, java.sql.Time, java.sql.Timestamp, oracle.sql.DATE, oracle.sql.TIMESTAMP, oracle.sql.TIMESTAMPTZ, oracle.sql.TIMESTAMPLTZ, and ZonedDateTime

java.util.Date, java.sql.Date, java.sql.Time, java.sql.Timestamp, LocalDateTime, and String

The different types supported by element input parameters can be seen in the table.

TIMESTAMP WITH TIME ZONE

java.sql.Date, Calendar, java.util.Date, LocalDate, LocalDateTime, LocalTime, OffsetDateTime, OffsetTime, String, java.sql.Time, java.sql.Timestamp, oracle.sql.DATE, oracle.sql.TIMESTAMP, oracle.sql.TIMESTAMPTZ, oracle.sql.TIMESTAMPLTZ, and ZonedDateTime

java.util.Date, java.sql.Date, java.sql.Time, java.sql.Timestamp, LocalDateTime, and String

  1. The different types supported by element input parameters can be seen in the table.
  2. The target types are inconsistent. For details, see differences in the getArray() API.

BLOB

oracle.sql.BLOB and oracle.jdbc.driver.OracleBlob

PGBlob

The different types supported by element input parameters can be seen in the table.

CLOB

oracle.sql.CLOB, oracle.jdbc.driver.OracleClob, InputStream, and Reader

PGClob

The different types supported by element input parameters can be seen in the table.

Set/Array

Array and Object

GaussArray and Object

  1. The different types supported by element input parameters can be seen in the table.
  2. Oracle Database: No error is reported when the input parameter is of the Array type even if the Array type differs from the element type.

    GaussDB: An error is reported when the input parameter is of the GaussArray type that differs from the element type.

  3. When the input parameter of an element is of the Object type, refer to the differences in array construction APIs.

RECORD

Struct and Object[]

GaussStruct and Object[]

  1. The different types supported by element input parameters can be seen in the table.
  2. Oracle Database: No error is reported when the input parameter is of the Struct type even if the Struct type differs from the element type.

    GaussDB: An error is reported when the input parameter is of the GaussStruct type that differs from the element type.

  3. When the input parameter of an element is of the Object[] type, refer to the differences in struct construction APIs.
  1. When an array is constructed, if the Java type of the input element does not match the target type, an implicit conversion operation is performed. For details on the Java types of input elements supported by various database element types, refer to the preceding table.
  2. GaussDB currently does not support the types unlisted in the aforementioned table.
  3. The constructor needs to provide an element array. The preceding table describes the differences between elements in the array.