Use an index on the table with your key values and call "INSERT OR
UPDATE INTO t(...) VALUES(...)" for all creation and update
operations. Unless you're dealing with a tremendous amount of data per
record this will be perfectly efficient.

On 11/28/06, Rich Shepard <[EMAIL PROTECTED]> wrote:
   This is a generic approach question, not neccesarily tied to a specific
database and certainly not to a particular language. For context, however,
my application is written in python and C and uses sqlite3. Here's the
situation:

   A database is created or opened, and the user enters data via fields on a
form. These data are then saved by inserting into the appropirate table and
fields. Now, if the user goes back to some of the fields and changes the
values in them, the table row should be updated, not re-inserted.

   What is the most efficient approach to test whether a record has a value
in a field that's different from the one displayed? The only approach that
occurs to me is to retrieve each field from the table and compare values
with those in the form when the "Save" button is clicked. If the field is
blank, then use an 'insert' statement; if the field has an existing value,
use an 'update' statement. Seems kludgy to me.

   Interestingly, I've not encounted this before with any database
application I've written, because they were all done in discrete steps. That
is, a menu was used to select whether new data were to be entered, or if
existing data were to be modified. With an event-driven GUI engine, and the
ability to modify the values in the widgets, it's a brand new game for me.

Thanks,

Rich

--
Richard B. Shepard, Ph.D.               |    The Environmental Permitting
Applied Ecosystem Services, Inc.(TM)    |            Accelerator
<http://www.appl-ecosys.com>     Voice: 503-667-4517      Fax: 503-667-8863

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------




--
Isaac Raway
Entia non sunt multiplicanda praeter necessitatem.

http://blueapples.org - blog
http://stonenotes.com - personal knowledge management

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to