显示从 psql 函数主体生成的一些值,如在 ES2016 中使用 console.log 所做的那样

showing some values generated from the body of a psql function as done with console.log in ES2016

在 ES2016 中,我们可以在执行函数时使用 console.log 来打印一些值。 psql 函数有类似的东西吗?

从未听说过 ES2016,但我认为您真正在谈论的是 PostgreSQL 中的 PL/pgSQL 函数。 psql 是该数据库的命令行客户端。

要在 PL/pgSQL 代码中将输出打印到控制台,请使用 RAISE NOTICE:

DO
$$BEGIN
   RAISE NOTICE '%, do you hear me?', current_user;
END;$$;