13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Working with local SQL databases in AIR<br />

<br />

<br />

<br />

<br />

<br />

<br />

Retrieving a database-g<strong>en</strong>erated primary key of an inserted row<br />

Adobe AIR 1.0 and later<br />

Oft<strong>en</strong> after inserting a row of data into a table, your code needs to know a database-g<strong>en</strong>erated primary key or row<br />

id<strong>en</strong>tifier value for the newly inserted row. For example, once you insert a row in one table, you might want to add<br />

rows in a related table. In that case you would want to insert the primary key value as a foreign key in the related table.<br />

The primary key of a newly inserted row can be retrieved using the SQLResult object associated with the statem<strong>en</strong>t<br />

execution. This is the same object that’s used to access result data after a SELECT statem<strong>en</strong>t is executed. As with any<br />

SQL statem<strong>en</strong>t, wh<strong>en</strong> the execution of an INSERT statem<strong>en</strong>t completes the runtime creates a SQLResult instance. You<br />

access the SQLResult instance by calling the SQLStatem<strong>en</strong>t object’s getResult() method if you’re using an ev<strong>en</strong>t<br />

list<strong>en</strong>er or if you’re using synchronous execution mode. Alternatively, if you’re using asynchronous execution mode<br />

and you pass a Responder instance to the execute() call, the SQLResult instance is passed as an argum<strong>en</strong>t to the result<br />

handler function. In any case, the SQLResult instance has a property, lastInsertRowID, that contains the row<br />

id<strong>en</strong>tifier of the most-rec<strong>en</strong>tly inserted row if the executed SQL statem<strong>en</strong>t is an INSERT statem<strong>en</strong>t.<br />

Last updated 6/6/2012<br />

746

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!