This article covers features introduced in Firefox 2
For an introduction see Storage.
mozIStorageStatement is defined in storage/public/mozIStorageStatement.idl
. It is scriptable
and
unfrozen (hasn't changed since Mozilla 1.8)
.
Inherits from: nsISupports
mozIStorageStatement
detects this error and will recompile the statement as needed. Therefore, once you create a statement, you don't need to worry about changing the schema; all statements will continue to transparently work.
. void initialize(in mozIStorageConnection aDBConnection, in AUTF8String aSQLStatement); Obsolete
|
void finalize();
|
mozIStorageStatement clone();
|
AUTF8String getParameterName(in unsigned long aParamIndex);
|
unsigned long getParameterIndex(in AUTF8String aName);
|
AUTF8String getColumnName(in unsigned long aColumnIndex);
|
unsigned long getColumnIndex(in AUTF8String aName);
|
void reset();
|
void bindUTF8StringParameter(in unsigned long aParamIndex, in AUTF8String aValue);
|
void bindStringParameter(in unsigned long aParamIndex, in AString aValue);
|
void bindDoubleParameter(in unsigned long aParamIndex, in double aValue);
|
void bindInt32Parameter(in unsigned long aParamIndex, in long aValue);
|
void bindInt64Parameter(in unsigned long aParamIndex, in long long aValue);
|
void bindNullParameter(in unsigned long aParamIndex);
|
void bindBlobParameter(in unsigned long aParamIndex, [array,const,size_is(aValueSize)] in octet aValue, in unsigned long aValueSize);
|
void execute();
|
boolean executeStep();
|
AString escapeStringForLIKE(in AString aValue, in wchar aEscapeChar);
|
| Attribute | Type | Description |
parameterCount
| unsigned long
| Number of parameters. |
columnCount
| unsigned long
| Number of columns returned. |
state
| long
| The current state. |
| Constant | Value | Description |
MOZ_STORAGE_STATEMENT_INVALID
| 0 | The SQL statement is Invalid. |
MOZ_STORAGE_STATEMENT_READY
| 1 | The SQL statement is ready to be executed. |
MOZ_STORAGE_STATEMENT_EXECUTING
| 2 | The SQL statement is executing at the moment. |
Obsolete
This method has been removed for Firefox 3.1. To initialize a statement, simply call the mozIStorageConnection
method createStatement()
; this works in Firefox 3.0 as well.
void initialize( in mozIStorageConnection aDBConnection, in AUTF8String aSQLStatement );
mozIStorageConnection
database connection.
Finalizes a statement so you can successfully close a database connection. since Gecko 1.9 M9
void finalize();
Creates a clone of the given statement, by initializing a new statement with the same connection and same SQL statement as specified one. It does not preserve statement state; that is, if a statement is being executed when it is cloned, the new statement will not be executing.
mozIStorageStatement clone();
Obtains the name of the parameter for the specified index.
AUTF8String getParameterName( in unsigned long aParamIndex );
Obtains the index of the parameter with the specified name.
unsigned long getParameterIndex( in AUTF8String aName );
Obtains the name of the column for the specified index.
AUTF8String getColumnName( in unsigned long aColumnIndex );
Obtains the index of the column with the specified name.
unsigned long getColumnIndex( in AUTF8String aName );
Reset parameters and statement execution.
void reset();
None.
Binds the UTF8String value to the parameter at aParamIndex. Index 0 denotes the first numbered argument or ?1.
void bindUTF8StringParameter( in unsigned long aParamIndex, in AUTF8String aValue );
Binds the String value to the parameter at aParamIndex. Index 0 denotes the first numbered argument or ?1.
void bindStringParameter( in unsigned long aParamIndex, in AString aValue );
Binds the Double value to the parameter at aParamIndex. Index 0 denotes the first numbered argument or ?1.
void bindDoubleParameter( in unsigned long aParamIndex, in double aValue );
Binds the Int32 value to the parameter at aParamIndex. Index 0 denotes the first numbered argument or ?1.
void bindInt32Parameter( in unsigned long aParamIndex, in long aValue );
Binds the Int64 value to the parameter at aParamIndex. Index 0 denotes the first numbered argument or ?1.
void bindInt64Parameter( in unsigned long aParamIndex, in long long aValue );
Binds the NULL value to the parameter at aParamIndex. Index 0 denotes the first numbered argument or ?1.
void bindNullParameter( in unsigned long aParamIndex );
Execute the query, ignoring any results. This is accomplished by calling step() method once, and then calling reset() method. Error and last insert info, etc. are available from the mozIStorageConnection
.
void execute();
The main way to execute a statement. This method executes a query, using any currently-bound parameters to enumerate all the result rows your statement produces, and will notify you when there are no more results available. The reset() method must be called on the statement after the last call of executeStep.
boolean executeStep();
Returns a boolean indicating whether there are more rows or not. Row data may be accessed using mozIStorageValueArray
methods on the statement.
Escape a string for SQL LIKE search.
...LIKE '?1' ESCAPE '/'...AString escapeStringForLIKE( in AString aValue, in wchar aEscapeChar );
An AString of an escaped version of aValue (%, _ and the escape char are escaped with the escape char). For example, we will convert "foo/bar_baz%20cheese" into "foo//bar/_baz/%20cheese" (if the escape char is '/').
Page last modified 16:07, 11 Jun 2008 by Sheppy