<p>I've written a database generation script in <a href="http://en.wikipedia.org/wiki/SQL" rel="noreferrer">SQL</a> and want to execute it in my <a href="http://en.wikipedia.org/wiki/Adobe_Integrated_Runtime" rel="noreferrer">Adobe AIR</a> application:</p>

<pre><code>Create Table tRole (
    roleID integer Primary Key
    ,roleName varchar(40)
);
Create Table tFile (
    fileID integer Primary Key
    ,fileName varchar(50)
    ,fileDescription varchar(500)
    ,thumbnailID integer
    ,fileFormatID integer
    ,categoryID integer
    ,isFavorite boolean
    ,dateAdded date
    ,globalAccessCount integer
    ,lastAccessTime date
    ,downloadComplete boolean
    ,isNew boolean
    ,isSpotlight boolean
    ,duration varchar(30)
);
Create Table tCategory (
    categoryID integer Primary Key
    ,categoryName varchar(50)
    ,parent_categoryID integer
);
...
</code></pre>

<p>I execute this in Adobe AIR using the following methods:</p>

<pre><code>public static function RunSqlFromFile(fileName:String):void {
    var file:File = File.applicationDirectory.resolvePath(fileName);
    var stream:FileStream = new FileStream();
    stream.open(file, FileMode.READ)
    var strSql:String = stream.readUTFBytes(stream.bytesAvailable);
    NonQuery(strSql);
}

public static function NonQuery(strSQL:String):void {
    var sqlConnection:SQLConnection = new SQLConnection();
    sqlConnection.open(File.applicationStorageDirectory.resolvePath(DBPATH));
    var sqlStatement:SQLStatement = new SQLStatement();
    sqlStatement.text = strSQL;
    sqlStatement.sqlConnection = sqlConnection;
    try {
        sqlStatement.execute();
    } catch (error:SQLError) {
        Alert.show(error.toString());
    }
}
</code></pre>

<p>No errors are generated, however only <code>tRole</code> exists. It seems that it only looks at the first query (up to the semicolon- if I remove it, the query fails). Is there a way to call multiple queries in one statement?</p>

[{'answer_id': 124, 'author': 'Shawn', 'author_id': 26, 'author_profile': 'https://Stackoverflow.com/users/26', 'pm_score': 5, 'selected': True, 'text': '<p>I wound up using this. It is a kind of a hack, but it actually works pretty well. </p>\n\n<p>The only thing is you have to be very careful with your semicolons. : D</p>\n\n<pre><code>var strSql:String = stream.readUTFBytes(stream.bytesAvailable);      \nvar i:Number = 0;\nvar strSqlSplit:Array = strSql.split(";");\nfor (i = 0; i &lt; strSqlSplit.length; i++){\n    NonQuery(strSqlSplit[i].toString());\n}\n</code></pre>\n'}, {'answer_id': 10008, 'author': 'Theo', 'author_id': 1109, 'author_profile': 'https://Stackoverflow.com/users/1109', 'pm_score': 3, 'selected': False, 'text': '<p>The <a href="http://en.wikipedia.org/wiki/SQLite" rel="noreferrer">SQLite</a> API has a function called something like <code>sqlite_prepare</code> which takes <em>one</em> statement and prepares it for execution, essentially parsing the SQL and storing it in memory. This means that the SQL only has to be sent once to the database engine even though the statement is executed many times.</p>\n\n<p>Anyway, a statement is a single SQL query, that\'s just the rule. The AIR SQL API doesn\'t allow sending raw SQL to SQLite, only single statements, and the reason is, likely, that AIR uses the <code>sqlite_prepare</code> function when it talks to SQLite.</p>\n'}, {'answer_id': 3770976, 'author': 'stats', 'author_id': 364174, 'author_profile': 'https://Stackoverflow.com/users/364174', 'pm_score': 2, 'selected': False, 'text': '<p>What about making your delimiter something a little more complex like ";\\n" which would not show up all that often. You just have to ensure when creating the file you have a line return or two in there. I end up putting two "\\n\\n" into the creation of my files which works well.</p>\n'}]
['https://Stackoverflow.com/questions/80', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/26/']