Postgresql 中文操作指南

CALL

CALL — 调用过程

CALL — invoke a procedure

Synopsis

CALL name ( [ argument ] [, ...] )

Description

CALL 执行过程。

CALL executes a procedure.

如果过程有任何输出参数,则将返回一个结果行,其中包含那些参数的值。

If the procedure has any output parameters, then a result row will be returned, containing the values of those parameters.

Parameters

  • name

    • The name (optionally schema-qualified) of the procedure.

  • argument

    • An argument expression for the procedure call.

    • Arguments can include parameter names, using the syntax name_ ⇒ _value. This works the same as in ordinary function calls; see Section 4.3 for details.

    • Arguments must be supplied for all procedure parameters that lack defaults, including OUT parameters. However, arguments matching OUT parameters are not evaluated, so it’s customary to just write NULL for them. (Writing something else for an OUT parameter might cause compatibility problems with future PostgreSQL versions.)

Notes

用户必须对过程有 EXECUTE 权限,才可以调用该过程。

The user must have EXECUTE privilege on the procedure in order to be allowed to invoke it.

若要调用函数(而不是过程),请使用 SELECT

To call a function (not a procedure), use SELECT instead.

如果 CALL 在事务块中执行,那么所调用的过程不能执行事务控制语句。只有当 CALL 在自己的事务中执行时,才允许事务控制语句。

If CALL is executed in a transaction block, then the called procedure cannot execute transaction control statements. Transaction control statements are only allowed if CALL is executed in its own transaction.

PL/pgSQL 在不同的 CALL 命令中处理输出参数的方式不同;参见 Section 43.6.3

PL/pgSQL handles output parameters in CALL commands differently; see Section 43.6.3.

Examples

CALL do_db_maintenance();

Compatibility

CALL 符合 SQL 标准,处理输出参数的情况除外。该标准规定,用户应当编写变量来接收输出参数的值。

CALL conforms to the SQL standard, except for the handling of output parameters. The standard says that users should write variables to receive the values of output parameters.