Wednesday, December 28, 2011

Postgresql query in transaction

The following is short example of query in transaction. We will delete all records and will insert new one in single transaction those actions both fails or both succeeds:
BEGIN;
DELETE FROM hi_value;
INSERT INTO hi_value(next_value) VALUES(5308);
COMMIT;