I have a very simple example for the summation of two numbers.
CREATE OR REPLACE FUNCTION add(a integer, b integer) RETURNS integer AS
$$
SELECT $1+$2;
$$ LANGUAGE 'sql';
My question is how to define a range b 10:20, whose values will counted up by one until the end of the range (20) is reached.
The result hast to be like this
res = a + b
res = a + 10
res = a + 11
res = a + 12
res = a + 13
When I retrieve the function add with:
SELECT add(1);
there should be the results: 11,12,13,...,21.
I didn't use loops like FOR EACH before (especially in the LANGUAGE sql).
Is it better to write those functions in plpgsql?