Hi I have more used with SQL procedure. Just trying to achieve below scenarios.
In Postgres Stored Procedure,
do we need to commit if there are multiple insert statements OR By default Postgressql handle commit and no need to mention (if we don't have anything to handle on Catch OR Rollback) ?
How to write , Try/Catch Or Rollback from Stored Procedure ?
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 , Do we need commit statement // HOW to handle if Rollback or Exception ? SELECT idIdentity as Id; / END
Can someone please guide on this.