Re: Moving around in a SQL database - Mailing list pgsql-sql

From Florian Reiser
Subject Re: Moving around in a SQL database
Date
Msg-id e2a034$1atq$1@news.hub.org
Whole thread Raw
In response to Re: Moving around in a SQL database  ("Florian Reiser" <florian.reiser@ra-bc.de>)
Responses Re: Moving around in a SQL database
List pgsql-sql
Hello Willem,

you are writing an edit mask?
Then do the following. Feed the mask with the data from the record.
If the user changes anything and presses the save button, then issue an
UPDATE .... WHERE ID=<id> to the database.

Always remember: you are working with a database, not with a dbf-file.
If your transaction fails because of power outage or anything else,
postgresql will revert to the consistent state before that transaction.
If you want to batch update the records, then do a

BEGIN TRANSACTION
SELECT .... FOR UPDATE.

After that collect the data you want to change.
Then issue your update statements.
After that do a

COMMIT TRANSACTION.

If anything fails between BEGIN and COMMIT TRANSACTION
all changes will be reverted to the state before the transaction.

With kind regards

Mit freundlichen Gr�ssen

Florian Reiser

-- 
http://www.ra-bc.de
RA Unternehmensberatung
F�hren durch pr�zise Daten

"WillemF" <jwhferguson@zoology.up.ac.za> schrieb im Newsbeitrag 
news:1145601779.703719.62700@i40g2000cwc.googlegroups.com...
> Thank you very much for your reply, Florian. It's probably the best
> that one can do. I have two complicating factors. Firstly, I need to
> udate the records one at a time and, secondly, I am accessing the table
> via a Java front end through JDBC. Loading all the data into memory
> opens the possibility for data corruption since, if anything goes wrong
> on the computer or power supply, there is no guarantee that all updates
> will have been written to file. Writing each update to file upon
> accessing each record again requires working with the whole table when
> manipulating a single record. The use of cursors is an elegant solution
> with the drawback that updates cannot be performed (that is, if I
> unerstand the documentation correctly!). Thank you very much for your
> time. Kind regards. Willem.
> 




pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: At time zone madness!
Next
From: Andreas Haumer
Date:
Subject: Porting application with rules and triggers from PG 7.4.x to 8.1.3