Rollback() on a single table??

Hi everyone,
How can I make a function to do rollback() of the records in one table, instead of entire database?

P.D: Sorry, my english is not very good.

Thanks!!

As long as you refer to a database transaction that’s not possible. A rollback reverts everything that has been changed inside a transaction. What tables were touched in that transaction is up to you.

Something like this:

function rollback(MyTable){
var editr = databaseManager.getEditedRecords()
for (x=0;x<editr.length;x++)
{
var jstable = databaseManager.getTable(editr);
var tableSQLName = jstable.getSQLName();
if(MyTable==tableSQLName) {
editr.rollbackChanges()
}
}
}

but, what about with new records??

sebamax2001:
but, what about with new records??

Good question.
When I run record.rollbackChanges() on a new record it does not rollback the record itself (like databaseManager.rollbackRecords() does) and it does not rollback any record data that has been entered after the record has been created.
Is this expected behaviour?

Cheers,
Maria

what can the rollbackChanges call to the record itself do?
It doesnt have changes to rollback… So call this on a new record object is a NOP (No Operation)

In the next version of servoy (6) you can give the databaseManager.rollbackRecords() call optional arguments like a foundset or records that needs to be rollbacked (and then also really cleared if it here new records)

jcompagner:
what can the rollbackChanges call to the record itself do?
It doesnt have changes to rollback… So call this on a new record object is a NOP (No Operation)

This is not exactly correct because databaseManager.getEditedRecords() returns my new record and myRecord.getChangedData() returns the record data.

Thanks for the news about Version 6, will be looking forward to it.

it is correct, databaseManager has those edited records, new or updated.
and both have changed data yes for updated only the columns that are changed and for new everything…
But a new one can’t rollback itself to something because it doesnt have old data…
Only the databaseManager can do that from the outside by really just removing the complete record (a record cant remove itself completely… so it depends on what object you ask it on)