Reputation: 3634
I'm trying to create a function, like so:
CREATE FUNCTION RETURNONE(DATE)
BEGIN
RETURN 1;
END
However, when I run this in psql 9.5 I get the following error:
ERROR: syntax error at or near "BEGIN"
LINE 2: BEGIN
^
END
I did see this other StackOverflow thread with a reminiscent problem. Per the second answer, I re-encoded my code in UTF 8, which did nothing. This is my first ever SQL function, so I'm sure I'm missing something painfully obvious. Let me know what!
Upvotes: 1
Views: 1040
Reputation: 656311
You omitted some essential syntax elements:
CREATE FUNCTION returnone(date)
RETURNS integer
LANGUAGE plpgsql AS
$func$
BEGIN
RETURN 1;
END
$func$;
The manual about CREATE FUNCTION
.
Upvotes: 1