在PL/PGSQL中,有没有办法提高计算?
我正在尝试测试一些代码,如果有一种方法可以像print()
或 console一样,那将是很棒的。 log()。
这是我的尝试,但不确定这是如何工作的:
DO
$cols$
DECLARE
qty_cols INT := 3;
current_month INT := ( SELECT EXTRACT(MONTH FROM DATE(NOW())) );
month_col INT;
BEGIN
FOR month_col IN 1..qty_cols LOOP
IF current_month < (month_col+1) THEN
--RAISE NOTICE (12+current_month) - month_col;
RAISE NOTICE '%', (12+current_month) - month_col;
ELSE
--RAISE NOTICE (current_month - month_col);
RAISE NOTICE '%', (12+current_month) - month_col;
END IF;
END LOOP;
END
$cols$;
我知道我可以使用%
符号来替换变量,但这似乎不仅仅是替换为变量...
I'm trying to test out some code, and it would be great if there was a way to RAISE NOTICE
like i would with print()
or console.log()
.
here is my attempt, but not sure how this works:
DO
$cols$
DECLARE
qty_cols INT := 3;
current_month INT := ( SELECT EXTRACT(MONTH FROM DATE(NOW())) );
month_col INT;
BEGIN
FOR month_col IN 1..qty_cols LOOP
IF current_month < (month_col+1) THEN
--RAISE NOTICE (12+current_month) - month_col;
RAISE NOTICE '%', (12+current_month) - month_col;
ELSE
--RAISE NOTICE (current_month - month_col);
RAISE NOTICE '%', (12+current_month) - month_col;
END IF;
END LOOP;
END
$cols$;
i know that i can use %
symbols to replace variables, but this doesn't seem like just substituting into a variable...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
提高通知期望以下参数,该参数是具有
%
占位符的格式字符串,将在其中放置后续参数。随后的论点可以是计算最少的单个后续参数格式字符串看起来像:
尽管意图可能更具描述性:
RAISE NOTICE expects a following argument that is a format string with
%
placeholders, into which the subsequent arguments will be placed. The subsequent arguments can be calculationsMinimally a format string for a single subsequent argument would look like:
Though the intent is perhaps to be more descriptive: