I’m new to Servoy and I’d like to acheive the following functionality:
In a form I want to put fields from multiple tables and a button that says “Create”.
I want the user to fill the form. When he’s done, he clicks on the “Create” button and then and only then the rows are created into the different tables (all within the same sql transaction).
I’m looking for an all-or-nothing behavior so that if the transaction fails the database is kept clean (ie: not the case if some tables have a record added and others tables don’t).
But you can also use transactions that you can roll back if the user does not hit “Save”.
The only question I have there is how that transaction is handled if several tables are involved. But as far as I have seen transactions work, related data is also rolled back. But maybe a statement from Servoy would be helpful on this question.
I think if you use transactions it would go along the following lines:
on loadform event
starttransaction
end loadform event
user fills out all the form fields (“creating” new records as needed)
on saveformevent (maybe on a button)
var check = function that verifies if all conditions are met and returns OK or NOTOK
if(check == “OK”)
commit
else
rollback
inform user
end if
closeform
patrick:
The only question I have there is how that transaction is handled if several tables are involved. But as far as I have seen transactions work, related data is also rolled back. But maybe a statement from Servoy would be helpful on this question.
An transaction encapsulates all changes done by client on any server/table. (meaning it will rollback all and any change in records/foundsets since the transaction is started)