Morten, i just burst my own bubble. It appears not to be working after all.
It seems the line Sql_conn.openAsync( Sql_db ) in the build() method is
the problem, becuase when I change it to
Sql_conn.open( Sql_db ) everything works fine.
Do you have any other suggestions?
Jiri
Morten Barklund wrote:
Hi Jiri,
I believe it is due to the default lock type. The default lock type (DEFERRED)
description says:
* SQLTransactionLockType.DEFERRED indicates that a lock is not acquired until
the first read or write operation.
And since a "CREATE" is technically neither a data read or data write, but a
scheme altering method, it could be the cause. Try changing the lock method be explicitly
specifying EXCLUSIVE as a parameter to begin():
Sql_conn.begin(SQLTransactionLockType.EXCLUSIVE);
Hope that helps,
Regards,
Morten Barklund
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jiri Heitlager
Sent: Wednesday, April 16, 2008 5:02 PM
To: Flash Coders List
Subject: [Flashcoders] Question AIR Sqlite api
I have a question about SQLite and AIR. Does anybody know why I get this
error, becuase the connection is open? I put the code below. The weird
thing is that when I use openAsync instead of open, it does work?
<error>
Error: Error #3105: Operation is only allowed if a connection has an
open transaction.
at Error$/throwError()
at flash.data::SQLConnection/commit()
at
classes.models::SQLProxy/createDatabase()[/Users/Jiri/Documents/_Flash/SmsApp/SmsApplication/src/classes/models/SQLProxy.as:128]
Debug session terminated.
</error>
<code>
protected function build():void
{
Sql_db =
File.applicationDirectory.resolvePath('TESTER.db')
var exists:Boolean = Sql_db.exists
if ( exists ) {
Sql_conn.addEventListener(SQLEvent.OPEN ,
onDBStatementOpenResult);
}else {
Sql_conn.addEventListener(SQLEvent.OPEN ,
createDatabase);
}
Sql_conn.openAsync( Sql_db )
}
private function createDatabase(e:Event):void
{
Sql_conn.addEventListener(SQLEvent.COMMIT ,
onDatabaseCreated);
Sql_conn.begin();
var createTable:SQLStatement = new SQLStatement()
createTable.sqlConnection = Sql_conn
createTable.text = 'CREATE TABLE contacts (index_id INTEGER PRIMARY
KEY , name TEXT , phone NUMBER )';
createTable.execute();
var createErrors:SQLStatement = new SQLStatement()
createErrors.sqlConnection = Sql_conn
createErrors.text = 'CREATE TABLE errors (index_id INTEGER PRIMARY
KEY , error_id INTEGER , type TEXT )';
createErrors.execute();
var createArchive:SQLStatement = new SQLStatement()
createArchive.sqlConnection = Sql_conn
createArchive.text = 'CREATE TABLE sms_archive (index_id INTEGER
PRIMARY KEY , sms TEXT , receiver NUMBER , sender NUMBER )';
createArchive.execute();
Sql_conn.commit();
}
</code>
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders