OK, I am having a conversation with myself here, but I have made it
work.
Here was the problem in my real application.
After inserting into the table Walks, I used
var testi=db.execute('SELECT last_insert_rowid() From Walks');
to get the last inserted rowid.
I have discovered that the transaction works if I immediately close
the result set testi .
Closing it after the Commit/Rollback in a {finally clause is too late
apparently.
I hope this helps somebody, somewhere. Comments welcome
Most of my problems so far using this stuff has come from not closing
result sets.
Now it seems with transactions where you close them is critical too.
Rambler
On Nov 3, 2:41 pm, rambler <[EMAIL PROTECTED]> wrote:
> Let me put it another way.
> Has ANYBODY got transactions working?
> If so, would you please post a simple working example.
> Rambler
>
> On Nov 1, 12:40 pm, rambler <[EMAIL PROTECTED]> wrote:
>
> > Hello All
> > I have followed the example to insert a record using BEGIN/COMMIT/
> > ROLLBACK
> > I always get
> > Error - Not Saved Database operation failed. ERROR: SQL logic error or
> > missing database DETAILS: SQL logic error or missing database
>
> > The Table Walks exists. This code works without BEGIN/COMMIT/ROLLBACK.
> > I realise transactions are for multiple executes, but surely this
> > simple case should work?
>
> > Am I missing something obvious here?
> > It's driving me nuts!
> > TIA
>
> > Rambler
>
> > var pos='Test';
> > var db = google.gears.factory.create('beta.database');
> > db.open('stored_walks');
>
> > db.execute('BEGIN');
>
> > try {
> > db.execute('insert into Walks
> > (WalkX,WalkY,WalkName,Timestamp) VALUES (?, ?, ?, ?)', [100, 200, pos,
> > new Date().getTime()]);
> > db.execute('COMMIT');
> > } catch(exp) {
> > alert("Error - "+e.message);
> > db.execute('ROLLBACK');
> > } finally {
> > db.close();
> > }
>
> > }