Closed OpakAlex closed 8 years ago
Now i use SET TRANSACTION NAME 'some-name'
if it's good?
I would build all SQLs into a BEGIN .. END
block at string level:
So instead of
session.prep_sql("BEGIN").exec_stmt()
session.prep_sql(sql1).exec_stmt()
session.prep_sql(sql2).exec_stmt()
session.prep_sql("COMMIT").exec_stmt()
I would
session.prep_sql("BEGIN "++sql1++" "++sql2++" COMMIT END").exec_stmt()
I don't know elixir syntax, so assumed ++
is supported as in erlang
Example: https://github.com/K2InformaticsGmbH/erloci/blob/master/test/erloci_test.erl#L699-L754
However
SET TRANSACTION NAME 'some-name'
gives you better control, as you can COMMIT
or ROLLBACK
as separate statements.
In the end your choice of approach will depend on your use case requirement.
ok, good i can use SET TRANSACTION NAME 'some-name'
i like it.
Thanks!
We have some sql for create 2 tables.
and next
I have my sessions in pool:
Next i run some command:
It's works, but i want wrap in transaction...
How i can do it?