【问题】
I have a simple postgresql query which returns three fields. I want to repeat that query in a loop. My “solution” right now is copy&paste the query several times with union, but this is not flexible. I want to repeat the query the number of times indicated in a parameter by the user. How can I do that?
【回答】
重复 N 遍结果集,可以用 SPL 简单实现,代码如下:
| A | |
|---|---|
| 1 | =$select f1,f2,f3 from tb |
| 2 | =A1*argN |
A1:查询数据
A2:对结果集重复 argN 遍,argN 是参数
使用SPL在PostgreSQL中动态重复查询
博客讨论了如何避免在SQL查询中使用复制粘贴来重复查询结果。作者提出了使用SPL(一种扩展SQL的语言)来实现根据用户参数动态重复查询的功能。这种方法允许用户指定一个参数,查询将根据该参数的值重复执行多次。
687

被折叠的 条评论
为什么被折叠?



