Re: [sqlite] Update vs Insert

2009-09-22 Thread Jay A. Kreibich
On Tue, Sep 22, 2009 at 11:31:16AM -0500, logan.rat...@emerson.com scratched on the wall: > > I am having problems with the update command (through the interface > > library). In most databases if you issue an update to a record that > > does not exist, it simply adds a new record. When I try

Re: [sqlite] Update vs Insert

2009-09-22 Thread Simon Slavin
On 22 Sep 2009, at 5:06pm, Barton Torbert wrote: > I am having problems with the update command (through the interface > library). Which interface library ? The sqlite3_ C calls ? Or a library or API for some other language ? > In most databases if you issue an update to a record that

Re: [sqlite] Update vs Insert

2009-09-22 Thread Logan.Ratner
>You can't do that with an 'update' but you can with 'insert or replace.' >This is true in any SQL driven database, not just SQL. (Er, that should read 'not just SQLite.') Logan Ratner | Software Engineer | Gas Chromatographs Emerson Process Management | 5650 Brittmoore Rd | Houston | TX | 77041

Re: [sqlite] Update vs Insert

2009-09-22 Thread Logan.Ratner
>From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users->boun...@sqlite.org] On Behalf Of Barton Torbert >Sent: Tuesday, September 22, 2009 11:07 AM >To: General Discussion of SQLite Database >Subject: [sqlite] Update vs Insert > >Hello, > >I am having problems with

Re: [sqlite] Update vs Insert

2009-09-22 Thread Igor Tandetnik
Barton Torbert wrote: > I am having problems with the update command (through the interface > library). In most databases if you issue an update to a record that > does not exist, it simply adds a new record. No database I've ever heard of does that. It must be a feature

[sqlite] Update vs Insert

2009-09-22 Thread Barton Torbert
Hello, I am having problems with the update command (through the interface library). In most databases if you issue an update to a record that does not exist, it simply adds a new record. When I try this in SQLite I get an error back. Is the SQLite update restricted to a record you know

[sqlite] Update on Insert

2007-10-01 Thread Hugo Ferreira
Hi everyone! I'm trying to solve the following problem... Suppose every access to the database is made as INSERTs (even UPDATEs). Whenever someone tries to insert something ovver an existing row (i.e., same PK), that insert should be treated as an update. Example: CREATE TABLE X ( c1 varchar,

Re: [sqlite] Update and insert questions

2007-02-16 Thread P Kishor
On 2/16/07, Jim Crafton <[EMAIL PROTECTED]> wrote: > but it fails because the embedded WHERE clause is no longer catching > the row. It is still looking for > > WHERE LastName='Doe' AND > FirstName='John' AND > Address='100 Nowhere Ave.' AND > Age=45; > > instead of > > WHERE

Re: [sqlite] Update and insert questions

2007-02-16 Thread drh
"Jim Crafton" <[EMAIL PROTECTED]> wrote: > So I guess the moral of this is to use bind cautiously :) > Bind is usually considered the safer way of doing things since it make SQL injection attachs much less likely. -- D. Richard Hipp <[EMAIL PROTECTED]>

Re: [sqlite] Update and insert questions

2007-02-16 Thread Jim Crafton
but it fails because the embedded WHERE clause is no longer catching the row. It is still looking for WHERE LastName='Doe' AND FirstName='John' AND Address='100 Nowhere Ave.' AND Age=45; instead of WHERE LastName='Doe' AND FirstName='Jane' AND Address='100 Nowhere Ave.' AND Age=45;

Re: [sqlite] Update and insert questions

2007-02-16 Thread Dennis Cote
Jim Crafton wrote: 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. I'm using the sqlite3_bind functions to modify the values. Second time, the WHERE clause doesn't match because you

Re: [sqlite] Update and insert questions

2007-02-16 Thread Dennis Cote
Jim Crafton wrote: I thought that the plain "?" character was an indicator that you were going to modify the column value via the sqlite3_bindXXX functions. You are correct. These parameters should not be quoted. Dennis Cote

Re: [sqlite] Update and insert questions

2007-02-16 Thread P Kishor
I guess I wasn't clear (either that, or I am not understanding what you are doing). Let's try again (and, it doesn't matter that you are using sqlite3_bind; I am just talking workflow here). You have the following row -- Doe John 100 Nowhere Ave.

RE: [sqlite] Update and insert questions

2007-02-16 Thread RB Smissaert
I did say I was nearly new to SQLite. RBS -Original Message- From: Jim Crafton [mailto:[EMAIL PROTECTED] Sent: 16 February 2007 16:28 To: sqlite-users@sqlite.org Subject: Re: [sqlite] Update and insert questions On 2/16/07, RB Smissaert <[EMAIL PROTECTED]> wrote: > Nearly new

Re: [sqlite] Update and insert questions

2007-02-16 Thread Jim Crafton
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. I'm using the sqlite3_bind functions to modify the values. Second time, the WHERE clause doesn't match because you have changed the

Re: [sqlite] Update and insert questions

2007-02-16 Thread Jim Crafton
On 2/16/07, RB Smissaert <[EMAIL PROTECTED]> wrote: Nearly new to SQLite as well, but shouldn't this: UPDATE Person SET LastName=?, FirstName=?, Address=?, Age=? Be altered to this: UPDATE Person SET LastName='?', FirstName='?', Address='?', Age='?' I thought that the plain "?" character

Re: [sqlite] Update and insert questions

2007-02-16 Thread P Kishor
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

[sqlite] Update and insert questions

2007-02-16 Thread Jim Crafton
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

Re: [sqlite] update or insert.

2006-06-30 Thread Jens Miltner
Am 27.06.2006 um 22:15 schrieb [EMAIL PROTECTED]: My brain does not seem to be able to function properly today. I can think of many ways to do what I want to do but none of them I like. I will describe the problem in the most symplistic form. I have two tables. The first table, has a row

[sqlite] update or insert.

2006-06-27 Thread Mario . Hebert
My brain does not seem to be able to function properly today. I can think of many ways to do what I want to do but none of them I like. I will describe the problem in the most symplistic form. I have two tables. The first table, has a row which includes an 'id' pointing to a row of another