I am not sure how the CREATE FUNCTION
statement works in PostgreSQL. I want to define a function (just for entertainment) such that given a number n, it prints asterisks starting from 1 up to n
So I wrote this:
CREATE FUNCTION asterisks(n int)
RETURNS CHAR AS
BEGIN
for i in range(1,n+1):
print("*"*i + "\n")
END
LANGUAGE python
The result I want for n=3
:
*
**
***
However, I am not sure if calling Python like that is possible. I've read that Postgres supports Python as a procedural language in here:
https://www.postgresql.org/docs/current/xplang.html