public class InsertionBuilder extends QueryBuilder<InsertionBuilder,java.lang.Long>
INSERT
query.
long nID = QueryBuilder.insertInto( sTableName ) .setValues( vals ) .executeOn( db ) ;Insert a row, specifying that the operation should be rolled back if a conflict arises.
long nID = QueryBuilder.insertInto( sTableName ) .setValues( vals ) .onConflict( SQLiteDatabase.CONFLICT_ROLLBACK ) .executeOn( db ) ;Insert a series of rows.
VectorvnIDs = new Vector<>() ; for( ContentValues vals : aSeveralValues ) { long nID = QueryBuilder.insertInto( sTableName ) .setValues( vals ) .executeOn( db ) ; if( nID != SQLitePortal.INSERT_FAILED ) vnIDs.add(nID) ; }
SQLiteDatabase.insertWithOnConflict(String, String, ContentValues, int)
QueryBuilder.UnboundException
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
LOG_TAG |
protected java.lang.String |
m_sNullableColumn
Specifies the column to use, if any, for the Android "null column hack"
during insertion.
|
protected int |
m_zConflictAlgorithmID
The numeric ID of the conflict resolution algorithm provided by Android.
|
m_asExplicitWhereParams, m_dbTarget, m_sExplicitWhereFormat, m_sTableName, m_valsToWrite
Constructor and Description |
---|
InsertionBuilder(java.lang.String sTableName) |
Modifier and Type | Method and Description |
---|---|
java.lang.Long |
executeOn(android.database.sqlite.SQLiteDatabase db)
Executes an insertion query on the values that have been appended to the
builder.
|
InsertionBuilder |
onConflict(int zAlgorithmID)
Selects, by its numeric ID, the conflict resolution algorithm provided by
Android.
|
java.lang.String |
toString()
Constructs a raw SQL
INSERT query based on the attributes of the
builder instance. |
InsertionBuilder |
withNullable(java.lang.String sColumnName)
Sets the name of the nullable column to be used for the Android "null
column hack".
|
deleteFrom, deleteFrom, execute, getWhereClause, getWhereFormat, getWhereParams, insertInto, insertInto, onDatabase, selectFrom, selectFrom, setTableName, setValues, toSQLInputParams, update, update, where, where, where
protected static final java.lang.String LOG_TAG
protected java.lang.String m_sNullableColumn
protected int m_zConflictAlgorithmID
SQLiteDatabase.CONFLICT_ABORT
,
SQLiteDatabase.CONFLICT_FAIL
,
SQLiteDatabase.CONFLICT_IGNORE
,
SQLiteDatabase.CONFLICT_NONE
,
SQLiteDatabase.CONFLICT_REPLACE
,
SQLiteDatabase.CONFLICT_ROLLBACK
public InsertionBuilder withNullable(java.lang.String sColumnName)
sColumnName
- the name of a nullable columnpublic InsertionBuilder onConflict(int zAlgorithmID)
zAlgorithmID
- the ID of the algorithm to usepublic java.lang.Long executeOn(android.database.sqlite.SQLiteDatabase db)
executeOn
in class QueryBuilder<InsertionBuilder,java.lang.Long>
db
- the database instance on which the query should be executed.SQLiteSyntax.INSERT_FAILED
if the row could not be insertedpublic java.lang.String toString()
INSERT
query based on the attributes of the
builder instance.toString
in class java.lang.Object
INSERT
query