Closed bt-maps closed 2 years ago
pgmoon issues the query string exactly as provided to the database server. Both the examples you gave will work. From what I remember, postgres will create an implicit transaction for each string sent as a query. If you need explicit control over the transaction then you can use BEGIN
, etc. as needed.
Does pgmoon support postgresql transactions when sending multiple queries like below?
local res, num_queries = pg:query([[ UPDATE accounts SET balance = balance - 100.00 WHERE name = 'Alice'; UPDATE accounts SET balance = balance - 155.00 WHERE name = 'Bob'; ]])
Or would we need to use a raw string to wrap the queries with BEGIN; UPDATE accounts SET balance = balance - 100.00 WHERE name = 'Alice'; UPDATE accounts SET balance = balance - 155.00 WHERE name = 'Bob'; -- etc etc COMMIT;