FileDocCategorySizeDatePackage
Stmt.javaAPI DocAndroid 1.5 API7746Wed May 06 22:41:06 BST 2009SQLite

Stmt

public class Stmt extends Object
Class to represent compiled SQLite3 statement. Note, that all native methods of this class are not synchronized, i.e. it is up to the caller to ensure that only one thread is in these methods at any one time.

Fields Summary
private long
handle
Internal handle for the SQLite3 statement.
protected int
error_code
Internal last error code for prepare()/step() methods.
Constructors Summary
Methods Summary
public native voidbind(int pos, java.lang.String value)
Bind positional String to compiled SQLite3 statement.

param
pos parameter index, 1-based
param
value value of parameter, may be null

public native voidbind(int pos)
Bind positional SQL null to compiled SQLite3 statement.

param
pos parameter index, 1-based

public native voidbind(int pos, int value)
Bind positional integer value to compiled SQLite3 statement.

param
pos parameter index, 1-based
param
value value of parameter

public native voidbind(int pos, long value)
Bind positional long value to compiled SQLite3 statement.

param
pos parameter index, 1-based
param
value value of parameter

public native voidbind(int pos, double value)
Bind positional double value to compiled SQLite3 statement.

param
pos parameter index, 1-based
param
value value of parameter

public native voidbind(int pos, byte[] value)
Bind positional byte array to compiled SQLite3 statement.

param
pos parameter index, 1-based
param
value value of parameter, may be null

public native intbind_parameter_count()
Return number of parameters in compiled SQLite3 statement.

return
int number of parameters

public native intbind_parameter_index(java.lang.String name)
Return index of named parameter in compiled SQLite3 statement.

param
name of parameter
return
int index of parameter, 1-based

public native java.lang.Stringbind_parameter_name(int pos)
Return name of parameter in compiled SQLite3 statement.

param
pos parameter index, 1-based
return
String parameter name

public native voidbind_zeroblob(int pos, int length)
Bind positional zero'ed blob to compiled SQLite3 statement.

param
pos parameter index, 1-based
param
length byte size of zero blob

public native voidclear_bindings()
Clear all bound parameters of the compiled SQLite3 statement.

public native voidclose()
Close the compiled SQLite3 statement.

public java.lang.Objectcolumn(int col)
Retrieve column data as object from exec'ed SQLite3 statement.

param
col column number, 0-based
return
Object or null


                                      

         

                                                                                                                                                                                                            

         

              

         

                  

         

                  

         

                           

            

                           

            

                           

            

                              

            

                             

            

                      

          

                             

          
     

                      

         

                          

          

                            

        
     


                         

          

                         
          

                         
          

                         
          

                         
          

                           
          

                      

         

                           

          
        switch (column_type(col)) {
    case Constants.SQLITE_INTEGER:
        return new Long(column_long(col));
    case Constants.SQLITE_FLOAT:
        return new Double(column_double(col));
    case Constants.SQLITE_BLOB:
        return column_bytes(col);
    case Constants.SQLITE3_TEXT:
        return column_string(col);
    }
    return null;
    
public native byte[]column_bytes(int col)
Retrieve blob column from exec'ed SQLite3 statement.

param
col column number, 0-based
return
byte[] column value

public native intcolumn_count()
Retrieve number of columns of exec'ed SQLite3 statement.

return
int number of columns

public native java.lang.Stringcolumn_database_name(int col)
Return database name of column of SQLite3 statement.

param
col column number, 0-based
return
String or null

public native java.lang.Stringcolumn_decltype(int col)
Return declared column type of SQLite3 statement.

param
col column number, 0-based
return
String or null

public native doublecolumn_double(int col)
Retrieve double column from exec'ed SQLite3 statement.

param
col column number, 0-based
return
double column value

public native intcolumn_int(int col)
Retrieve integer column from exec'ed SQLite3 statement.

param
col column number, 0-based
return
int column value

public native longcolumn_long(int col)
Retrieve long column from exec'ed SQLite3 statement.

param
col column number, 0-based
return
long column value

public native java.lang.Stringcolumn_origin_name(int col)
Return origin column name of column of SQLite3 statement.

param
col column number, 0-based
return
String or null

public native java.lang.Stringcolumn_string(int col)
Retrieve string column from exec'ed SQLite3 statement.

param
col column number, 0-based
return
String column value

public native java.lang.Stringcolumn_table_name(int col)
Return table name of column of SQLite3 statement.

param
col column number, 0-based
return
String or null

public native intcolumn_type(int col)
Retrieve column type from exec'ed SQLite3 statement.

param
col column number, 0-based
return
column type code, e.g. SQLite.Constants.SQLITE_INTEGER

protected native voidfinalize()
Destructor for object.

private static native voidinternal_init()
Internal native initializer.

public native booleanprepare()
Prepare the next SQL statement for the Stmt instance.

return
true when the next piece of the SQL statement sequence has been prepared, false on end of statement sequence.

public native voidreset()
Reset the compiled SQLite3 statement without clearing parameter bindings.

public native booleanstep()
Perform one step of compiled SQLite3 statement. Example:
...
try {
Stmt s = db.prepare("select * from x; select * from y;");
s.bind(...);
...
s.bind(...);
while (s.step(cb)) {
Object o = s.value(...);
...
}
// s.reset() for re-execution or
// s.prepare() for the next piece of SQL
while (s.prepare()) {
s.bind(...);
...
s.bind(...);
while (s.step(cb)) {
Object o = s.value(...);
...
}
}
} catch (SQLite.Exception e) {
s.close();
}

return
true when row data is available, false on end of result set.