I have this code to create a function. But it tells me the command in BEGIN is wrong
CREATE FUNCTION transform_activebool(activebool CHAR(1))
RETURNS VARCHAR(10)
BEGIN
IF activebool = 't' THEN
RETURN 'Active';
ELSE
RETURN 'Inactive';
END IF;
END;
I tried moving the syntax and looking at the BEGIN
command and it’s not working.
2
Answers
try this:
Use valid syntax. In this case you can use a simple SQL function, using a CASE to select the correct output:
This function is so simple, there is no need for the plpgsql language and thus no need for BEGIN and END.