Contents
DO
An SQL command for executing an anonymous code block
DO
is a command for executing an anonymous code block.
DO
was added in PostgreSQL 9.0.
Change history
- PostgreSQL 9.0
- added (commit 9048b731)
Examples
Basic usage examples for DO
:
postgres=# DO LANGUAGE plpgsql $$ BEGIN RAISE NOTICE 'hello world'; END; $$; NOTICE: hello world DO postgres=# DO LANGUAGE plperlu $$ elog NOTICE, 'hello world'; $$; NOTICE: hello world DO
It is not possible to execute a DO
block with SQL
:
postgres=# DO LANGUAGE SQL $$ SELECT 'hello world'; $$; ERROR: language "sql" does not support inline code execution
References
- PostgreSQL documentation: DO