Created
January 8, 2013 21:21
-
-
Save emersoncortez/4488069 to your computer and use it in GitHub Desktop.
Demostración de transacciones en PostreSQL.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- La cuenta A será cargada (se le quitará) y | |
-- la cuenta B será abonada (se le sumará) | |
-- Inicio de la transacción | |
BEGIN; | |
-- Cargando la cuenta A. | |
UPDATE cuentas SET saldo_cuenta = saldo_cuenta - monto WHERE nombre_cuenta = 'A'; | |
-- Abonando la cuenta B. | |
UPDATE cuentas SET saldo_cuenta = saldo_cuenta + monto WHERE nombre_cuenta = 'B'; | |
-- Cerrando la transacción si todo salió bien. | |
COMMIT; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment