databaseManager.rollbackTransaction(); triggers Save first

Hi,

I noticed that databaseManager.rollbackTransaction(); triggers a Save first, before starting the RollBack.

In the situation I’m looking at, this causes a problem, because inside the transaction is a new record in a table with a couple of fields that are not nullable and the not nullable columns are not filled yet.

So, when databaseManager.rollbackTransaction(); is called, I get an errormessage from the Database saying that the record cannot be saved, since null cannot be inserted into not nullable columns.

I tried capturing the error with application.setErrorCapture(true);, but Database errors do not seem to get captured.

Is this expected behavior?

The situation I’m looking at is where a new Record is shown in a FormIndialog in Record view. The form has a Cancel button. When clicked, the new Record has to be disragarded and the FormInDialog closed. Also, when the “X” of the FormInDialog is closed, the same has to happen.

I can get the Cancel button to work properly, by adding a deleteRecord command before the rollback of the transaction, but when I do this in the method I have attached to the onHode of the form in the Dialog, this workaround doesn’t help, presumably because clikcing the “X” fires a Save to the DB directly, before the onHide method is called.

How can I get this to work?

Paul

PS: see the topic below for the basic setup of the situation:

Paul,

will my tip at http://www.servoymagazine.com help you in this case?

Cheers

Allthough I’ve been using the Try and Catch function in many area’s allready for quite some time, I haven’t tried it here.

Will give it a go, but it doesn’t seem to be a nice solution to the problem.

Paul

I agree Paul but it might help you out :)

Just tried to try it, but no avail…

The save happens when the X is clicked, even before any method is fired in which I could place the Try and Catch… At least that is how it looks in the debugger.

When I click the X while debugging is enabled, the error appears before any part of a method is executed

So, I don’t think there is anything I can do from a scripting point of view…

Paul

Anyone?

Still have the following situation:
A Form in dialog in Record view with a new record for a table that has not nullable columns.

A Transaction rollback fired by a button on the form with throw a Database error, since before the transaction is roilled back, a save is done and the record cannot be saved, because some of the not nullable columns do not have a value filled yet

And a click on the X of the FID will also fire a Save before the onHide method is fired, causing a DB error for the saem reason.

Can this be fixed somehow?

Paul

pbakker:
Transaction rollback fired by a button on the form with throw a Database error, since before the transaction is roilled back, a save is done and the record cannot be saved, because some of the not nullable columns do not have a value filled yet

Might it work to start the method that is attached to that button with a statement that plunks dummy values into the “not nullable” columns?

And a click on the X of the FID will also fire a Save before the onHide method is fired, causing a DB error for the saem reason

This is just an untested “stab in the dark” … try using an onRecordSave method to do the same thing (fill blank no-null fields with values) and then delete that record?? (warning, wild guess from a newbie!)

Nomi

Hi Nomi,

For the first issue, I allready have a workaround: Delete the record before starting the RollBack.

For the second one, I do not have a workaround, since the error occurs before the onHide method is fired.

Paul

I am still searching for an elegant solution to the problem mentioned above. In my solution I have a form with an onShow method that performs:
databaseManager.startTransaction
controller.newRecord

Initally I ran into problems when clicking in the “grey area” that the record would try to auto save before all fields were entered. So I put
application.setFocusLostSaveEnabled(false)
into the onShow Method.

All fine and good, but if the user decides halfway through entering data to go somewhere else, I am having trouble deleting the partially completed new record and rolling back the transaction. I can’t seem to get away without an error being thrown about non null fields with null values. I tried playing around with onHide and onRecordSave methods, but neither presented a feasible solution.

Any tricks?

I had the same problem with a form. The solution is to have a method fired by the delete button that in case of a new record puts dummy values into not null fields. This way you can delete the record without receiving any error message.

rioba,

I did try that, but unfortunatley it doesn’t help when the user clicks a buttin on my controller to go to another form rather then clicking some “delete” button. I tried putting the form into a pop up dialog box, but similar problems occur with the “X”

wgknowles:
All fine and good, but if the user decides halfway through entering data to go somewhere else, I am having trouble deleting the partially completed new record and rolling back the transaction. I can’t seem to get away without an error being thrown about non null fields with null values. I tried playing around with onHide and onRecordSave methods, but neither presented a feasible solution.

Any tricks?

I know it may seem too simplistic, but what about NOT letting the user leave the form without committing or rolling back?