Is there any difference between:
CREATE FUNCTION func() RETURNS integer
LANGUAGE plpgsql AS $$
declare
begin
-- do something
end
$$;
and
CREATE FUNCTION func() RETURNS INTEGER AS $$
declare
begin
-- do something
end
$$ LANGUAGE plpgsql;
Does LANGUAGE plpgsql basically just have to be outside the scope of the $$ usage?
No difference whatsoever.
The function body is a string literal. The $$ are just dollar-quotes and could be single quotes, too (but better use dollar quotes!):
CREATE FUNCTION is a declarative SQL-DDL command, and the order of keywords is pretty free, as per definition in the manual. (Key words within the curly braces in the command definition can be arranged freely, but not the rest).
I eventually settled on always putting the language declaration on top with the rest of the function header, before the function body. Makes more sense.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With