Can you please guide what is wrong with below code which gives an issue with below error:
ERROR: invalid transaction termination.
CREATE OR REPLACE PROCEDURE "app"."sproc_data_create"
( name varchar(100))
LANGUAGE plpgsql
AS
$$
Declare idIdentity int;
BEGIN
INSERT INTO data(Name) VALUES (name) RETURNING Id into idIdentity;
INSERT INTO relationalData(dataId) VALUES (idIdentity);
COMMIT;
END
For below scenarios, this does not work executing commit for one insert statement and expected to rollback second insert statement. This rollback both insert statements.
BEGIN
INSERT INTO data(Name) VALUES (name) RETURNING Id into idIdentity;
COMMIT;
INSERT INTO relationalData(dataId) VALUES (idIdentity);
END
Execute below script:
/*
do
begin
CALL "app"."sproc_data_create"("name field")
end
*/
//invalid transaction termination
CONTEXT: PL/pgSQL function