Gestire gli errori

Transazioni e gestione degli errori in PostgreSQL

Jason Myers

Principal Engineer

Gli errori capitano

Aggiornato per errore Biscuits

UPDATE cookies SET quantity = 13 WHERE name = 'Biscuits';

Corretto per aggiornare Biscotti

UPDATE cookies SET quantity = 1 WHERE name = 'Biscuits';

UPDATE cookies SET quantity = 13 WHERE name = 'Biscotti';
Transazioni e gestione degli errori in PostgreSQL

Annullare gli errori

BEGIN TRANSACTION

UPDATE cookies SET quantity = 13 WHERE name = 'Biscuits';
ROLLBACK;
SELECT quantity FROM cookies where name = 'Biscuits';
13
Transazioni e gestione degli errori in PostgreSQL

Rollback di più istruzioni

BEGIN TRANSACTION;

UPDATE cookies SET deliciousness = 111 where name = 'Cats Tongue';

UPDATE cookies SET deliciousness = 8 where name = 'Gingerbread';

ROLLBACK;
SELECT name, deliciousness FROM cookies where name in ('Cats Tongue', 'Gingerbread');
'Cats Tongue'  10
'Gingerbread'   9
Transazioni e gestione degli errori in PostgreSQL

Passons à la pratique !

Transazioni e gestione degli errori in PostgreSQL

Preparing Video For Download...