mozIStorageValueArray
From MDC
This article covers features introduced in Firefox 2
mozIStorageValueArray wraps an array of SQL values, such as a single database row.
You can get the type of a value by calling getTypeOfIndex(), which returns the type of the specified column.
For an introduction see Storage
Contents |
mozIStorageValueArray is defined in storage/public/mozIStorageValueArray.idl. It is scriptable and
unfrozen (hasn't changed since Mozilla 1.8). mozIStorageStatement implements mozIStorageValueArray.
Inherits from: nsISupports
[edit] Method overview
long getTypeOfIndex(in unsigned long aIndex);
|
long getInt32(in unsigned long aIndex);
|
long long getInt64(in unsigned long aIndex);
|
double getDouble(in unsigned long aIndex);
|
AUTF8String getUTF8String(in unsigned long aIndex);
|
AString getString(in unsigned long aIndex);
|
void getBlob(in unsigned long aIndex, out unsigned long aDataSize, [array,size_is(aDataSize)] out octet aData);
|
boolean getIsNull(in unsigned long aIndex);
|
[edit] Attributes
| Attribute | Type | Description |
numEntries
| unsigned long
| The number of entries in the array (each corresponding to a column in the database row). |
[edit] Constants
| Constant | Value | Description |
VALUE_TYPE_NULL
| 0 | Null data type. |
VALUE_TYPE_INTEGER
| 1 | INTEGER data type.
|
VALUE_TYPE_FLOAT
| 2 | FLOAT data type.
|
VALUE_TYPE_TEXT
| 3 | TEXT data type.
|
VALUE_TYPE_BLOB
| 4 | BLOB data type.
|
[edit] Methods
[edit] getTypeOfIndex()
Returns the type of the value at the given column index; one of VALUE_TYPE_NULL, VALUE_TYPE_INTEGER, VALUE_TYPE_FLOAT, VALUE_TYPE_TEXT, or VALUE_TYPE_BLOB.
long getTypeOfIndex( in unsigned long aIndex );
[edit] Parameters
- aIndex
- The index of the column whose type you wish to determine.
[edit] Return value
One of VALUE_TYPE_NULL, VALUE_TYPE_INTEGER, VALUE_TYPE_FLOAT, VALUE_TYPE_TEXT, or VALUE_TYPE_BLOB.
[edit] getInt32()
Returns an Int32 value for the given entry (column) index. Due to SQLite's type conversion rules, any of these are valid for any column regardless of the column's data type. However, if the specific type matters, call getTypeOfIndex() first to identify the column type, and then the appropriate get method should be called.
long getInt32( in unsigned long aIndex );
[edit] Parameters
- aIndex
- The index of the column whose value is to be returned.
[edit] Return value
Returns an Int32 value for the given entry (column) index.
[edit] getInt64()
Returns an Int64 value for the given entry (column) index. Due to SQLite's type conversion rules, any of these are valid for any column regardless of the column's data type. However, if the specific type matters, call getTypeOfIndex() first to identify the column type, and then the appropriate get method should be called.
long long getInt64( in unsigned long aIndex );
[edit] Parameters
- aIndex
- The index of the column whose data should be retrieved.
[edit] Return value
Returns an Int64 value for the given entry (column) index.
[edit] getDouble()
Returns a Double value for the given entry (column) index. Due to SQLite's type conversion rules, any of these are valid for any column regardless of the column's data type. However, if the specific type matters, call getTypeOfIndex() first to identify the column type, and then the appropriate get method should be called.
double getDouble( in unsigned long aIndex );
[edit] Parameters
- aIndex
- The column's index.
[edit] Return value
Returns a Double value for the given entry (column) index.
[edit] getUTF8String()
Returns an AUTF8String value for the given entry (column) index. Due to SQLite's type conversion rules, any of these are valid for any column regardless of the column's data type. However, if the specific type matters, call getTypeOfIndex() first to identify the column type, and then the appropriate get method should be called.
If you ask for a string value for a NULL column, you will get an empty string with IsVoid set to distinguish it from an explicitly set empty string.
AUTF8String getUTF8String( in unsigned long aIndex );
[edit] Parameters
- aIndex
- The column's index.
[edit] Return value
Returns an AUTF8String value for the given entry (column) index.
[edit] getString()
Returns an AString value for the given entry (column) index. Due to SQLite's type conversion rules, any of these are valid for any column regardless of the column's data type. However, if the specific type matters, call getTypeOfIndex() first to identify the column type, and then the appropriate get method should be called.
If you ask for a string value for a NULL column, you will get an empty string with IsVoid set to distinguish it from an explicitly set empty string.
AString getString( in unsigned long aIndex );
[edit] Parameters
- aIndex
- The column's index.
[edit] Return value
Returns an AString value for the given entry (column) index.
[edit] getBlob()
Retrieves unformatted data from the column specified by the given index. The returned data is NULL if dataSize = 0.
void getBlob( in unsigned long aIndex, out unsigned long aDataSize, [array,size_is(aDataSize)] out octet aData );
[edit] Parameters
- aIndex
- The column's index.
- aDataSize
- The size of the returned data.
- aData
- The returned data.
[edit] getIsNull()
Checks if given column index is NULL or not.
boolean getIsNull( in unsigned long aIndex );
[edit] Parameters
- aIndex
- The column's index.
[edit] Return value
Returns true or false depending on whether or not the data in the column specified by aIndex is null.
[edit] Example: Using get functions to retrieve values
[edit] C++
PRBool hasMoreData;
while (NS_SUCCEEDED(statement->ExecuteStep(&hasMoreData)) && hasMoreData) {
PRInt32 value = statement->AsInt32(0);
// use the value...
}
[edit] JavaScript
while (statement.executeStep()) {
var value = statement.getInt32(0);
// use the value...
}
[edit] See also
- Storage mozStorage introduction and how-to article
- mozIStorageConnection Database connection to a specific file or in-memory data storage
- mozIStorageStatement Create and execute SQL statements on a SQLite database.
- mozIStorageFunction Create a new SQLite function.
- mozIStorageAggregateFunction Create a new SQLite aggregate function.
- mozIStorageProgressHandler Monitor progress during the execution of a statement.
- mozIStorageStatementWrapper Storage statement wrapper