Creating a Function in Postgres - ERROR: syntax error at or near "end"

Viewed 392

I am currently working on a little database for a project, I have to work with a Postgresql instance for which I am trying to write a function to no avail. I have tried a few different versions now, stripped my task down to the basics, but for the love of god cannot get the function to be stored let alone executed. Maybe someone could point out what the issue is here exactly. I have taken a look at the default functions but no matter what I try it wont save.

create or replace 
function public.insertLeuchten(art integer)
    returns bool as
$$
begin 
    insert into public.artikel(rowid, artikelnummer) values(default, art)
    returning rowid
end;
$$ language 'plpgsql';

_

create or replace 
function public.insertLeuchten(art integer)
    returns void as
$$
begin 
    insert into public.artikel(rowid, artikelnummer) values(default, art)
end;
$$ language 'plpgsql';

Error

ERROR: syntax error at or near "end"
  Position: 168
1 Answers

Apart from the comment by a_horse_with_no_name - you don't even need the begin and end clauses here:

create or replace function public.insertLeuchten(art integer)
$$
    insert into public.artikel(rowid, artikelnummer) values(default, art)
$$ language sql;
Related