SQL 在 postgresql 中打印变量的值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23465429/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 01:48:05  来源:igfitidea点击:

printing a value of a variable in postgresql

sqlpostgresql

提问by Rustam Issabekov

I have a postgresql function

我有一个 postgresql 函数

CREATE OR REPLACE FUNCTION fixMissingFiles() RETURNS VOID AS $$
DECLARE
    deletedContactId integer;
    BEGIN
            SELECT INTO deletedContactId contact_id FROM myContacts WHERE id=206351;

            -- print the value of deletedContactId variable to the console

    END;
$$ LANGUAGE plpgsql;

How can I print the value of the deletedContactId to the console?

如何将deletedContactId 的值打印到控制台?

回答by Denis de Bernardy

You can raise a notice in Postgresas follows:

您可以通过以下方式发出通知Postgres

raise notice 'Value: %', deletedContactId;

Read here

在这里阅读