ERROR: syntax error at or near "END" LINE 9: END; ^ SQL state: 42601 Character: 350 ===========================
My procedure
CREATE OR REPLACE PROCEDURE proc_insert(empid bigint,ename character varying(256),
email character varying(256),enum bigint,
eadd bigint)
language 'plpgsql'
as $$
BEGIN
insert into proc_insert(empid,ename,email,enum,eadd)
END;
$$;
CodePudding user response:
Missing semicolon after the command.
CREATE OR REPLACE PROCEDURE proc_insert(empid bigint
, ename varchar
, email varchar
, enum bigint
, eadd bigint)
LANGUAGE plpgsql AS
$proc$
BEGIN
INSERT INTO proc_insert -- add target column list!
VALUES(empid,ename,email,enum,eadd);
END
$proc$;
(While the one after END
is optional.)
Plus, your INSERT
statement was broken anyway. I fixed it, but you better add a target column list, too. See:
CodePudding user response:
You are getting this error because your insert query syntax is incorrect.
create or replace PROCEDURE proc_insert(empid bigint,ename character varying(256),
email character varying(256),enum bigint,
eadd bigint)
LANGUAGE plpgsql AS $$
declare
begin
insert into proc_insert values(empid,ename,email,enum,eadd);
end
$$;
Demo in DBfiddle