Subject Re: [firebird-support] Store Procedure for updating data, why it is need to commit?
Author Mark Rotteveel
On 28 Apr 2014 22:23:43 -0700, <trskopo@...> wrote:
> I have a simple stored procedure to update data, like this :
>
> SET TERM ^ ;
> CREATE PROCEDURE REG
> AS
> BEGIN
> UPDATE table a set a.field1 = '123';
> exit;
> END^
> SET TERM ; ^

There is no need for a EXIT statement in this stored procedure.

> When I run that procedure on flamerobin with this command:
> execute procedure Reg.
>
> It runs ok, but without a commit command, the field1 on table won't get
> update.
> I rarely use store procedure to do update / insert / delete, but is
this
> a normal behavior?

Of course a commit is necessary, the stored procedure runs in the
transaction that executed the stored procedure. As long as that transaction
hasn't been committed, the change is only visible to that transaction. This
is the same as if you had executed the UPDATE without a stored procedure.

> Is there any commands to add so commit is no needed?

If you really want to (but I don't see why you would), you can use `IN
AUTONOMOUS TRANSACTION DO`:
http://www.firebirdsql.org/file/documentation/reference_manuals/reference_material/html/langrefupd25-psql-autonomous-trans.html

Mark