匿名函数 postgresql 的返回值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10314963/
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-10-20 23:51:22 来源:igfitidea点击:
Return value from anonymous function postgresql
提问by Arturgspb
How to?
如何?
For easy example. I have a simple function:
举个简单的例子。我有一个简单的功能:
DO LANGUAGE plpgsql $$ DECLARE
BEGIN
EXECUTE 'SELECT NOW()';
END $$;
How I can return value of "NOW()" or other values from also anonymous function? The function is given as an example I have a more complex function.
我如何从匿名函数返回“NOW()”的值或其他值?以函数为例,我有一个更复杂的函数。
回答by vyegorov
It is not an anonymous function, but rather anonymous code block.
它不是匿名函数,而是匿名代码块。
- if you need to returnvalues, consider creating real functions;
- if you need to output some debug info, just
RAISE NOTICE
.
- 如果您需要返回值,请考虑创建真正的函数;
- 如果您需要输出一些调试信息,只需
RAISE NOTICE
.
回答by Clodoaldo Neto
DO LANGUAGE plpgsql $$ DECLARE
BEGIN
execute '
create temporary table t
as
SELECT NOW()
';
END $$;
select * from t;