118 | Chapter 4: AIR Mini-Cookbook
"last TEXT )";
stmt.execute();
In this case, aCREATE TABLE statement has been applied to
the database. Additional types of SQL statements, such as
SELECT,INSERT,UPDATE, andDELETEare executed in the same
manner. The SQLStatement.execute( )method can take two
optional arguments: the number of rows to prefetch, and a
responder object to handle events.
The prefetch option defaults toβ1, which indicates that all
rows should be returned. The responder object can be a cus-
tom object designed to handle any status or result events that
take place during execution. The default responder is null in
this case, as event handlers have been registered with the
SQLStatement object directly:
<html>
<head>
<title>Creating Database Tables</title>
<script type="text/javascript" src="AIRAliases.js">
</script>
<script>
var db = null;
var stmt = null
function doDbOpen( event )
{
stmt =new air.SQLStatement();
stmt.addEventListener( air.SQLErrorEvent.ERROR,
doStmtError );
stmt.addEventListener( air.SQLEvent.RESULT,
doStmtResult );
stmt.sqlConnection = db;
stmt.text = "CREATE TABLE IF NOT EXISTS contact ( " +
"id INTEGER PRIMARY KEY AUTOINCREMENT, " +
"first TEXT, " +
"last TEXT )";
stmt.execute();
}