HomeMogDBMogDB StackUqbar
v5.0

Documentation:v5.0

Supported Versions:

Other Versions:

DO

Function

Execute an anonymous block of code.

A code block is viewed as a piece of function body with no arguments and a return value of type void. its parsing and execution occur at the same moment.

Or, it executes an expression and does not return a result.

Precautions

Compared to the original MogDB, dolphin's changes to the DO syntax are:

The DO expr_list syntax is added to the original syntax to execute expressions without returning results.

Syntax

DO [ LANGUAGE lang_name ] code;

Or

DO expr[,expr...];

Parameter Description

  • lang_name

    The name of the program language used to parse the code; if default, the default language is plpgsql.

  • code

    Program language code that can be executed. The program language must be specified as a string for this to work.

  • expr

    Expressions, multiple expressions are separated using commas, and expression support is referenced to Expression

Examples

-- Executes the expression and does not return a result.
MogDB=# DO 1;

MogDB=# DO pg_sleep(1);

-- Execute multiple expressions without returning results.

MogDB=# DO 1+2;
Copyright © 2011-2024 www.enmotech.com All rights reserved.