[yunqa.de] Re: Need comments about SQLite Error 1 - no such rowid: 0

  • From: Delphi Inspiration <delphi@xxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Tue, 18 Jan 2011 20:54:48 +0100

On 18.01.2011 09:03, Edwin Yip wrote:

>         FDb.StartTransaction;
>         Stmt := FDb.Prepare('update Docs set Content=? where DocId=?');
> 
>         Stmt.Bind_ZeroBlob(1, srcFile.Size);
> 
>         Stmt.Bind_int(2, aDoc.DocId);
> 
>         Stmt.Step;
>         //so far so good, so I think the row id 0 exists, whereas the
>     error msg says 'no such rowid'.

UPDATE statements do not return any results. Also, if no row matches
your WHERE clause, the update will still finish normally and will not
throw any errors. So your code above does not allow you to conclude that
a particular row exists.

To check if a table contains a particular RowID, execute a query like

  SELECT 1 FROM table WHERE RowID = ?

The row exists if Stmt.Step returns SQLITE_ROW.

Ralf
_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: