OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

SQL - V4.1.0Enterprise Edition

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & Certification
    Company
    About OceanBaseTrust CenterLegalPartnerContact Us
    Follow Us

    © OceanBase 2026. All rights reserved

    Cloud Service AgreementPrivacy PolicySecurity
    Contact Us
    Document Feedback
    1. Documentation Center
    2. OceanBase Database
    3. SQL
    4. V4.1.0
    iconOceanBase Database
    SQL - V 4.1.0Enterprise Edition
    SQL
    KV
    • V 4.4.2
    • V 4.3.5
    • V 4.3.3
    • V 4.3.1
    • V 4.3.0
    • V 4.2.5
    • V 4.2.2
    • V 4.2.1
    • V 4.2.0
    • V 4.1.0
    • V 4.0.0
    • V 3.1.4 and earlier

    DEFINE_ARRAY

    Last Updated:2023-07-28 02:53:17  Updated
    share
    What is on this page
    Scalar and LOB types of the collection
    Syntax
    Parameters
    Considerations

    folded

    share

    The DEFINE_ARRAY stored procedure defines the collection into which the row values are fetched, with a FETCH_ROWS function call, for a given column.

    The DEFINE_ARRAY stored procedure can use a single SELECT statement to retrieve multiple rows and pass them to COLUMN_VALUE as parameters.

    Applicability

    This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL mode.

    Scalar and LOB types of the collection

    You can declare local variables as the following types and use DBMS_SQL to fetch any number of rows into them. These types can be the same as those specified by the BIND_ARRAY stored procedure.

    TYPE binary_double_table
                        IS TABLE OF BINARY_DOUBLE  INDEX BY BINARY_INTEGER;
    TYPE binary_float_table
                        IS TABLE OF BINARY_FLOAT   INDEX BY BINARY_INTEGER;
    TYPE bfile_table     IS TABLE OF BFILE          INDEX BY BINARY_INTEGER;
    TYPE blob_table     IS TABLE OF BLOB           INDEX BY BINARY_INTEGER;
    TYPE clob_table     IS TABLE OF CLOB           INDEX BY BINARY_INTEGER;
    TYPE date_table     IS TABLE OF DATE           INDEX BY BINARY_INTEGER;
    TYPE interval_day_to_second_Table
                        IS TABLE OF dsinterval_unconstrained
                                                   INDEX BY BINARY_INTEGER;
    TYPE interval_year_to_MONTH_Table
                        IS TABLE OF yminterval_unconstrained
                                                   INDEX BY BINARY_INTEGER;
    TYPE number_table   IS TABLE OF NUMBER         INDEX BY BINARY_INTEGER;
    TYPE time_table     IS TABLE OF time_unconstrained           
                                                   INDEX BY BINARY_INTEGER;
    TYPE time_with_time_zone_table
                        IS TABLE OF time_tz_unconstrained
                                                   INDEX BY BINARY_INTEGER;
    TYPE timestamp_table
                        IS TABLE OF timestamp_unconstrained   
                                                   INDEX BY BINARY_INTEGER;
    TYPE timestamp_with_ltz_Table
                        IS TABLE OF timestamp_ltz_unconstrained
                                                   INDEX BY BINARY_INTEGER;
    TYPE timestamp_with_time_zone_Table
                        IS TABLE OF timestamp_tz_unconstrained
                                                   INDEX BY BINARY_INTEGER;
    TYPE urowid_table   IS TABLE OF UROWID         INDEX BY BINARY_INTEGER;
    TYPE varchar2_table IS TABLE OF VARCHAR2(2000) INDEX BY BINARY_INTEGER;
    

    Syntax

    DBMS_SQL.DEFINE_ARRAY (
    c                   IN INTEGER,
    position            IN INTEGER,
    <table_variable>    IN <datatype>
    cnt                 IN INTEGER,
    lower_bnd           IN INTEGER);
    

    <table_variable> and the corresponding <datatype> can be combined into any of the following matching pairs, and DEFINE_ARRAY is reloaded to accept different data types:

    <n_tab>      Number_Table
    <c_tab>      Varchar2_Table
    <d_tab>      Date_Table
    <bl_tab>     Blob_Table
    <cl_tab>     Clob_Table
    

    Parameters

    Parameter Description
    c The ID of the cursor to be bound to the array.
    position The relative position of the column in the defined array. This value starts at 1.
    table_variable The local variable that has been declared as <datatype>.
    cnt The number of rows to be fetched.
    lower_bnd The lower-bound index, starting from which the results are copied to the collection.

    Considerations

    • The value of (cnt) must be an integer greater than 0; otherwise, an exception will be thrown.

    • The value of lower_bnd can be a positive number, a negative number, or 0.

    • Queries that call DEFINE_ARRAY cannot contain array bindings.

    Previous topic

    DEFINE_COLUMN
    Last

    Next topic

    DESCRIBE_COLUMNS
    Next
    What is on this page
    Scalar and LOB types of the collection
    Syntax
    Parameters
    Considerations