Save Or Update
Siminov Framework edited this page Jan 17, 2016
·
10 revisions
public final void saveOrUpdate() throws DatabaseException;
Note
- If tuple is not present in table then it will insert it into table else it will update the tuple.
Book c = new Book();
c.setTitle(Book.BOOK_TYPE_C);
c.setDescription(applicationContext.getString(R.string.c_description));
c.setAuthor(applicationContext.getString(R.string.c_author));
c.setLink(applicationContext.getString(R.string.c_link));
try {
c.saveOrUpdate();
} catch(DatabaseException de) {
//Log it.
}
- (void)saveOrUpdate;
Note
- If tuple is not present in table then it will insert it into table else it will update the tuple.
Book *c = [[Book alloc] init];
[c setTitle:[Book BOOK_TYPE_C]];
[c setDescription:@"c_description"];
[c setAuthor:@"c_author"];
[c setLink:@"c_link"];
@try {
[c saveOrUpdate];
} @catch(SICDatabaseException *databaseException) {
//Log it.
}
public void SaveOrUpdate();
Note
- If tuple is not present in table then it will insert it into table else it will update the tuple.
Book c = new Book();
c.SetTitle(Book.BOOK_TYPE_C);
c.SetDescription("c_description");
c.SetAuthor("c_author");
c.SetLink("c_link");
try
{
c.SaveOrUpdate();
}
catch(DatabaseException de)
{
//Log it.
}
- this.saveOrUpdate = function() {};
- this.saveOrUpdate = function(callback, transaction) {};
/** Save Or Update Sample **/
var c = new Book();
c.setTitle(Book.BOOK_TYPE_C);
c.setDescription("c_description");
c.setAuthor("c_author");
c.setLink("c_link");
try {
c.saveOrUpdate();
} catch(DatabaseException de) {
//Log it.
}
/** Save Or Update Async Sample **/
var c = new Book();
c.setTitle(Book.BOOK_TYPE_C);
c.setDescription("c_description");
c.setAuthor("c_author");
c.setLink("c_link");
var callback = new Callback();
callback.onSuccess = function() {
}
c.saveOrUpdateAsync(callback);
/** Save Or Update Async Transaction Sample **/
var c = new Book();
c.setTitle(Book.BOOK_TYPE_C);
c.setDescription("c_description");
c.setAuthor("c_author");
c.setLink("c_link");
var callback = new Callback();
callback.onExecute = function(transaction) {
var saveOrUpdateCallback = new Callback();
saveOrUpdateCallback.onSuccess = function() {
}
c.saveOrUpdateAsync(saveOrUpdateCallback, transaction);
}
callback.onSuccess = function() {
}
var databaseDescriptor = c.getDatabaseDescriptor();
Database.beginTransactionAsync(databaseDescriptor, callback);