OceanBase logo

OceanBase

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

Product Overview
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

OceanBase

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

Product Overview
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.6.0

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogWhite PaperLive DemosTraining & CertificationTicket
    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.6.0
    iconOceanBase Database
    SQL - V 4.6.0
    Databases
    • OceanBase Database
    • OceanBase Cloud
    • OceanBase Tugraph
    • Interactive Tutorials
    • OceanBase Best Practices
    Tools
    • OceanBase Cloud Platform
    • OceanBase Migration Service
    • OceanBase Developer Center
    • OceanBase Migration Assessment
    • OceanBase Admin Tool
    • OceanBase Loader and Dumper
    • OceanBase Deployer
    • Kubernetes operator for OceanBase
    • OceanBase Diagnostic Tool
    • OceanBase Binlog Service
    Connectors and Middleware
    • OceanBase Database Proxy
    • Embedded SQL in C for OceanBase
    • OceanBase Call Interface
    • OceanBase Connector/C
    • OceanBase Connector/J
    • OceanBase Connector/ODBC
    • OceanBase Connector/NET
    SQL
    KV
    • V 4.6.0
    • 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

    Create a pipeline function

    Last Updated:2026-05-07 11:26:25  Updated
    Share
    What is on this page
    Syntax
    Syntax
    Data types
    Examples

    folded

    Share

    A pipeline function must be a standalone function or a packaged function. This topic describes how to create a pipeline function.

    Applicability

    This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition does not support this feature.

    Syntax

    The syntax of a pipeline function is as follows. For more information about the complete syntax of the CREATE FUNCTION statement, see CREATE FUNCTION. The syntax of the pipelined_clause is as follows:

    PIPELINED
    { [ USING [schema.] implementation_type ]
    | { ROW | TABLE } POLYMORPHIC [ USING [schema.] implementation_package ]
    }
    

    The syntax of the PIPE ROW clause is as follows:

    PIPE ROW ( row ) ;
    

    The syntax of the parallel_enable_clause is as follows:

    PARALLEL_ENABLE
    [ (PARTITION argument BY
        { ANY
        | { HASH | RANGE } (column [, column ]...) [ streaming_clause ]
        | VALUE (column)
        }
      )
    

    The syntax of the return_statement is as follows:

    RETURN [ expression ] ;
    

    Syntax

    • For a standalone function, specify the PIPELINED option in the CREATE FUNCTION statement. For a packaged function, specify the PIPELINED option in both the function declaration and the function definition.

    • We recommend that you specify the PARALLEL_ENABLE option to enable parallel execution of the pipeline function.

    • If a pipeline function runs DML statements, use PRAGMA AUTONOMOUS_TRANSACTION; to make it autonomous. After this statement is executed, an independent transaction is created for each instance of the function during parallel execution.

    • If you call a pipeline function multiple times in the same query or in separate queries, the underlying implementation is executed multiple times. If the function is deterministic, specify the DETERMINISTIC option.

    • Generally, a pipeline function has one or more cursor variable parameters. For more information about cursor variables, see Cursor variables.

    • In a pipeline function, use the PIPE ROW statement to return a collection element to the caller without returning control to the caller.

    • Each execution path in a function must end with a RETURN statement that returns control to the caller. However, in a pipeline function, the RETURN statement does not need to return a value to the caller.

    Data types

    The data type of the return value of a pipeline function must be a collection type defined at the schema level or in a package. It cannot be an associative array. The elements of a collection must be SQL data types, not PL/SQL data types such as PLS_INTEGER and BOOLEAN.

    You can use the SQL data types ANYTYPE and ANYDATA to dynamically encapsulate and access the type description, data instance, and data instance set of any other SQL type, including object and collection types.

    Examples

    obclient> CREATE OR REPLACE PACKAGE pkg_pi AUTHID DEFINER AS
            TYPE numset_tbl IS TABLE OF NUMBER;
            FUNCTION fuc(n NUMBER) RETURN numset_tbl PIPELINED;
          END pkg_pi;
          /
    Query OK, 0 rows affected
    
    obclient> CREATE OR REPLACE PACKAGE BODY pkg_pi AS
            FUNCTION fuc(n NUMBER) RETURN numset_tbl PIPELINED IS
            BEGIN
              FOR i IN 1..n LOOP
                PIPE ROW(i);
              END LOOP;
              RETURN;
            END fuc;
          END pkg_pi;
          /
    Query OK, 0 rows affected
    
    obclient> SELECT * FROM TABLE(pkg_pi.fuc(6));
    +--------------+
    | COLUMN_VALUE |
    +--------------+
    |            1 |
    |            2 |
    |            3 |
    |            4 |
    |            5 |
    |            6 |
    +--------------+
    5 rows in set
    
    obclient> SELECT * FROM TABLE(pkg_pi.fuc(3));
    +--------------+
    | COLUMN_VALUE |
    +--------------+
    |            1 |
    |            2 |
    |            3 |
    +--------------+
    2 rows in set
    

    Previous topic

    Overview of pipelined table functions
    Last

    Next topic

    Related applications
    Next
    What is on this page
    Syntax
    Syntax
    Data types
    Examples