Hi guys.
I have some questions about SQL functions in postgresql:
-
Can a SQL function call another SQL function?
-
How about recursive calls?
-
Consider we have function that has a varchar argument.
CREATE FUNCTION func(varchar) RETURN void AS $$
some SQL queries.
$$ LANGUAGE SQL;
Should we define the argument, varchar or we should define the length too like varchar(20)? How about return values?
4. consider this example:
we have table named student and a function like this: it only gets a student row and add that row to the student table.
CREATE FUNCTION add_new(student) RETURNS void AS $$
INSERT INTO student VALUES ($1);
$$ LANGUAGE SQL;
is this function syntactically right?
Thank you very much.