Repeat a Result Set Multiple Times

Question

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?

 

Answer

You can sue SPL (Structured Process Language) to repeat the query result set a number of times:

A

1

=$select f1,f2,f3 from tb

2

=A1*argN

A1: Data retrieval.

A2: Repeat the result set a number of times specified by parameter argN.