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.2.2

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive 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.2.2
    iconOceanBase Database
    SQL - V 4.2.2
    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

    Limitations on stored programs

    Last Updated:2026-04-15 08:27:15  Updated
    share
    What is on this page
    Limitations on SQL statements
    Limitations on stored functions
    Limitations on triggers
    Name conflicts in stored routines

    folded

    share

    This topic applies to all stored routines, namely stored procedures and stored functions. Some limitations are specific to stored functions and not stored procedures. The limitations on stored functions also apply to triggers. Triggers have their own specific limitations.

    Limitations on SQL statements

    Limitations of stored programs on SQL statements:

    • Stored routines cannot use the LOAD DATA statement.

    • Prepared SQL statements (PREPARE, EXECUTE, and DEALLOCATE PREPARE) can be used in stored procedures but not stored functions or triggers. Therefore, stored functions and triggers cannot use dynamic SQL statements.

    • Stored programs cannot use the statements that are not allowed in prepared SQL statements. However, exception handling statements such as SIGNAL, RESIGNAL, and GET DIAGNOSTICS, which cannot be used as prepared statements, can be used in stored programs.

    • A local variable takes effect only when the stored program is executed. Therefore, it cannot be referenced by a prepared statement created in the stored program. The prepared statement takes effect only for the current session instead of the stored program. Therefore, this statement can be executed after the program ends. At this time, the local variable is beyond the effective scope.

    • In all stored programs (stored procedures, stored functions, and triggers), the parser considers BEGIN[WORK] as a BEGIN... END block. To start a transaction in this context, use the START TRANSACTION statement.

    Limitations on stored functions

    The following statements or operations are not allowed in stored functions:

    • Statements for performing an explicit or implicit commit or rollback. The SQL standard does not require support for such statements. The standard stipulates that each DBMS vendor can decide whether to restrict them.

    • Statements that return a result set, such as the SELECT and SHOW statements without the INTO var_list clause, EXPLAIN statement, and CHECK TABLE statement. Functions can use the SELECT INTO clause or use a cursor and the FETCH statement to process a result set.

    • FLUSH statement.

    • Stored functions cannot be used in recursions.

    • If a table exists in the call statement (for reading or writing) of a function or trigger, the stored function or trigger cannot modify this table.

    The preceding statements can be used in stored procedures except those called from stored functions or triggers. For example, if you use the FLUSH statement in a stored procedure, you cannot call this stored procedure from a stored function or trigger.

    Limitations on triggers

    Take note of the following limitations on triggers:

    • A foreign key action cannot fire a trigger.

    • A trigger cannot return a value and therefore cannot contain the RETURN statement. To immediately exit a trigger, use the LEAVE statement.

    Name conflicts in stored routines

    A routine parameter, local variable, and table column can share the same identifier. The same local variable name can also be used in nested blocks. The following rules apply in such scenarios:

    • A local variable takes precedence over a routine parameter or a table column.

    • A routine parameter takes precedence over a table column.

    • A local variable in an internal block takes precedence over a local variable in an external block.

    Previous topic

    Trigger
    Last

    Next topic

    Overview
    Next
    What is on this page
    Limitations on SQL statements
    Limitations on stored functions
    Limitations on triggers
    Name conflicts in stored routines