Available in versions: Dev (3.18) | Latest (3.17) | 3.16 | 3.15 | 3.14

This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.

ARRAY_GET

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

The ARRAY_GET function allows for accessing array elements by 1-based ordinal.

SELECT (ARRAY[1, 2])[1]
create.select(arrayGet(array(1, 2), 1)).fetch();

The result would look like this:

+-----------+
| array_get |
+-----------+
|         1 |
+-----------+

Dialect support

This example using jOOQ:

arrayGet(array(1, 2), 1)

Translates to the following dialect specific expressions:

-- AURORA_POSTGRES, COCKROACHDB, H2, POSTGRES, YUGABYTEDB
(ARRAY[1, 2])[1]

-- HSQLDB
CASE
  WHEN cardinality(ARRAY[1, 2]) >= 1 THEN (ARRAY[1, 2])[1]
END

-- ACCESS, ASE, AURORA_MYSQL, BIGQUERY, DB2, DERBY, EXASOL, FIREBIRD, HANA, INFORMIX, MARIADB, MEMSQL, MYSQL, ORACLE, 
-- REDSHIFT, SNOWFLAKE, SQLDATAWAREHOUSE, SQLITE, SQLSERVER, SYBASE, TERADATA, VERTICA
/* UNSUPPORTED */

(These are currently generated with jOOQ 3.18, see #10141), or translate your own on our website

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo