Database - Update from Data Entry/Query form

Jan Schenkel janschenkel at
Mon Nov 24 15:30:11 EST 2003

--- Melvin Cox <melcox at> wrote:
> I have successfully implemented a "Query By Example"
> call from a button on 
> my data entry/query form.
> I am, however, having problems implementing an
> Update (Modify) statement.
> The script for the Update button uses global
> variables to hold the value of 
> each field within a row at the time that row is
> fetched (via "Query", "Next" 
> or "Previous").  These (saved) variables have a
> prefix of "s_" (ie. s_city, 
> s_state,  s_zip, etc.).
> The script also uses local variables to hold the
> value of each field at the 
> time the update is executed.  These (current)
> variables have a prefix of 
> "c_" (ie. c_city, c_state, c_zip, etc.).
> Functionality within a "mouseUp" handler compares
> the "saved" value of each 
> field to its "current" value, via a series of
> if/then/else statements and 
> places the elements of a SQL Update statement into
> "tSQLQuery".
> I have successfully tested the resulting syntax
> against my database, via 
> isql.
> However, when I attempt to execute modification of a
> field (or fields) from 
> the form, the update fails - each and every time.
> The triggering mechanism within my script is
> expressed as:
> "revSetSQLOfQuery "PeopleUpdate", tSQLQuery"
> I have also tested with the "revExecuteSQL" call.
> Is there a better means of executing the update? 
> How should I approach 
> "Add" button functionality?
> Your suggestions are most sincerely appreciated.
> Melvin Cox

Hi Melvin,

There are basically two ways of updating the records
in the database: either by ticking the checbox "Update
after editing" in the "Database" pane of the Property
Inspector ; or by writing an UPDATE query like you did

(You could adapt your closeField handler for this
purpose, and build a custom property set to hold the
changed fields' new contents.)

Once you have collected the necessary information into
a query, you can execute it via :
  revExecuteSQL <name of an existing query>, \
                <the SQL query to execute>
There's no need to change an existing query ;
revExecuteSQL needs the name of an existing query
solely for its database connection information.

If you still get an error, there is probably something
wrong with the query.

Hope this helped,

Jan Schenkel.

"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)

Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard

More information about the Use-livecode mailing list