Database consistency after a power shortage - Mailing list pgsql-sql

From Alberto
Subject Database consistency after a power shortage
Date
Msg-id AANLkTikURg8vNPTcM6PTABws18E-xZttR3=E+6UMnH=9@mail.gmail.com
Whole thread Raw
Responses Re: Database consistency after a power shortage
List pgsql-sql
My question is regarding a potential situation:<br /><br />I have a program that inserts values on 3 tables linked to
eachother. My program is used in a POS. In this specific case, the program has to update the tables "header_invoice",
"detail_invoice"and "payments_x_header_invoice". <br /><br />In a normal operation, the program should insert first a
registryon "header_invoice", then insert N registries on "detail_invoice" referencing the header_invoice number. After
thatit should insert N registries regarding the payments related to the header_invoice, referencing again the invoice.
<br/><br />So the order goes like this:<br />1) Insert 1 new registry on "header_invoice"<br />2) Insert N registries
on"detail_invoice" referencing header_invoice<br />3) Insert N registries on "payments_x_header_invoice" referencing
theheader_invoice<br /><br />If lets say the header_invoice registry was inserted, operation was committed and then a
powershortage occurs and the system shuts down. In that case the database will never know that more registries had to
beinserted, because that happened on the application level. <br /><br />Is there any way to make the 3 operations be
onetransaction for the database, so that it keeps them all consistent in case a power shortage occurs in the middle?<br
/>

pgsql-sql by date:

Previous
From: serviciotdf
Date:
Subject: Translate Function PL/pgSQL to SQL92
Next
From: Scott Marlowe
Date:
Subject: Re: Database consistency after a power shortage