On 2/16/07, Jim Crafton <[EMAIL PROTECTED]> wrote:
OK, please bear with me here, as I'm very much of an SQL newbie.

I'm writing a wrapper around sqlite.
I want the to code to be able to modify a given value (column) of a
specific row. To do this, as I understand it, I need to use the SQL
UPDATE statement coupled with a WHERE clause. So assuming the
following table :
CREATE TABLE Person
(
LastName varchar,
FirstName varchar,
Address varchar,
Age int
);


With a single row of:
Doe                   John                     100 Nowhere Ave.          45

I want to change "John" to "Bob".

If I want to update this, I would write
UPDATE Person SET LastName=?, FirstName=?, Address=?, Age=?
WHERE LastName='Doe' AND FirstName='John' AND Address='100 Nowhere
Ave.' AND Age=45;

I then use the sqlite bind APIs to change values accordingly.

The first time I execute this in sqlite, the sql execution succeeds.
The second time I execute this there is no change to the DB, but the
API calls don't return any error code!
If I change the "=" operator in the WHERE clause to "like" then the
operation makes the change to the DB.


well, the first time you update the row (and, you haven't said what
values you update it with), it succeeds because your WHERE clause
successfully matches.

Second time, the WHERE clause doesn't match because you have changed
the values. For example, if the first time you went and changed the
value of FirstName to 'Jane', the second time around your WHERE clause
won't match.

You might find thins a lot easier if you set a primary key in the
table, and use that to match the rows.

--
Puneet Kishor http://punkish.eidesis.org/
Nelson Inst. for Env. Studies, UW-Madison http://www.nelson.wisc.edu/
Open Source Geospatial Foundation http://www.osgeo.org/education/
---------------------------------------------------------------------
collaborate, communicate, compete
=====================================================================

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

Reply via email to