I am trying to create the following function in a postgres_9 database:
CREATE OR REPLACE FUNCTION getUser(IN user_id INT8)
RETURNS TABLE(id INT8, nom TEXT, prenom TEXT)
AS $$
BEGIN
SELECT id, nom, prenom
FROM security.users
WHERE id = user_id
END
$$ LANGUAGE sql;
But I get the following error:
ERROR: syntax error at or near "SELECT"
PS: I am new to Postgres databases. if you have good resources for tutorials and books on how to create functions and triggers in plpgsql or SQL for Postgres databases that would be great!
BEGIN
andEND
.ERROR: column "user_id" does not exist