Postgresql 中文操作指南

46.4. Anonymous Code Blocks #

PL/Python 也支持使用 DO 语句调用的匿名代码块:

PL/Python also supports anonymous code blocks called with the DO statement:

DO $$
    # PL/Python code
$$ LANGUAGE plpython3u;

匿名代码块不接收任何参数,并且它可能返回的任何值都会被丢弃。在其他方面,它的行为与函数完全一致。

An anonymous code block receives no arguments, and whatever value it might return is discarded. Otherwise it behaves just like a function.