Problem with databaseManager.saveData()

Hi All,

I have a problem with databaseManager.saveData() in my solution (Servoy Version : 5.1.4 - Build 964). Below is an example of the solution and not the actual solution.

databaseManger.setAutoSave(false);

var _success = false;
var _swap_serial_no = 'XXXXXXX';
var _original_serial_no = 'YYYYYYY';

var fs1 = databaseManager.getFoundSet('test', 'tbl_phones');
var fs2 = databaseManager.getFoundSet('test', 'tbl_phones');

if(fs1.find())
{
    fs1.serial_no = _swap_serial_no;
    fs1.unit_status = '100';
    fs1.search();

    if(fs1.getSize() > 0)
    {
        if(fs2.find())
        {
            fs2.serial_no = _original_serial_no;
            fs2.search();
   
            if(fs2.getSize() > 0)
            {
                fs1.customer_id = fs2.customer_id;
                fs1.unit_status = '200';

                fs2.swap_unit_id = fs1.unit_id;
                fs2.customer_id = null;

                _success = true;
            }
        }
    }
}

if(_success)
{
    // Some Functionalities
    function1();
    function2();

    //Finally
    application.output('Find Mode FS1 : ' + fs1.isInFind()); //Ref:1
    application.output('Customer ID : ' + fs1.customer_id + ' Unit Status : ' + fs1.unit_status ); //Ref:2
    _success = databaseManager.saveData();
    application.output('Data Saved Successfully : ' + _success); //Ref:3
    application.output('Customer ID : ' + fs1.customer_id + ' Unit Status : ' + fs1.unit_status ); //Ref:4
}

The problem is fs1 foundset is not saving. I like to mention here, this is happening only some times. Most of the times it saving correctly.

Further I have checked the fs1 foundset through output messages before saving (Ref:2) & after saving (Ref:4). All the times foundset has the correct values. However databaseManager.saveData() gives boolean value “true” (Ref:3).

And I have checked the foundset is in find mode or not by fs1.isInFind(). Always it give “false”.(Ref:1)

Now I’m stucked with this situation.

So Anyone could help me urgently, I’ll appreciate it.

When savedata gives “true” means success, data was correctly updated in DB. When “false” means it failed to update DB.

Hi Achiary,

achiary:
When savedata gives “true” means success, data was correctly updated in DB. When “false” means it failed to update DB.

That is the normal way(Logical). In my solution, it’s screwed up. So that is the problem on my side.

Nisala,

Can you reproduce the error with your example code?
You are saying it happens sometimes, maybe you can rewrite the sample to a loop and a check directly in the db (using for example databaseManager.getDataSetByQuery()) if the update worked.

Once you have a reproducible sample, please file a case on http://www.servoy.com/s so we can investigate.

Rob

Btw, is your code called from a table view (in smart client)? Table view is special internally because of code executing in multiple threads.