Package | com.ericfeminella.sql |
Interface | public interface ISQLStatementCache |
ISQLStatementCache
provides a marker interface implementation
which is intended to indicate that implementing classes serve as a repository
of uniquely defined SQLStatement
instances which are to be reused
throughout the lifetime of an application.
Adobe AIR best practices advocate that any SQL statement which is to be
executed more than once should have a separate SQLStatement
instance defined for each SQL statement.
For example, an application that includes various different SQL operations
which are to be performed multiple times should define seperate instances of
SQLStatement
, one for each specific operation. In order to improve
performance it is recommended to avoid using a single SQLStatement
instance for all SQL operations by assigning a new value to it's text
property each time before executing the statement.
ISQLStatementCache
is intended to be implemented by classes which
which define unique SQLStatement
or PreparedStatement
instances, one for each operation which is to be executes more than once.
ISQLStatementCache
implementation which defines seperate PreparedStatement
instances for
each statement which will be reused in the application.
package { import com.ericfeminella.sql.ISQLStatementCache; import com.ericfeminella.sql.PreparedStatement; import flash.data.SQLConnection; public final class FOOStatements implements ISQLStatementCache { public var INSERT:PreparedStatement; public var SELECT:PreparedStatement; public var UPDATE:PreparedStatement; public var DELETE:PreparedStatement; public function FOOStatements(connection:SQLConnection) { INSERT = new PreparedStatement( "INSERT into foo VALUES (?,?)", connection ); SELECT = new PreparedStatement( "SELECT FROM foo", connection ); UPDATE = new PreparedStatement( "UPDATE contacts SET bar=? WHERE id=?)", connection ); DELETE = new PreparedStatement( "DELETE FROM foo WHERE id=?", connection ); } } }
See also