# data not pushed to MySQL

**URL:** <https://forum.servoy.com/t/data-not-pushed-to-mysql/14080>\
**Category:** Classic Servoy\
**Created:** [May 31, 2011, 8:47pm UTC](https://forum.servoy.com/t/data-not-pushed-to-mysql/14080 "2011-05-31T20:47:13Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![jkipling](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@jkipling](https://forum.servoy.com/u/jkipling)\
**Post date:** [May 31, 2011, 8:47pm UTC](https://forum.servoy.com/t/data-not-pushed-to-mysql/14080/1 "2011-05-31T20:47:13Z")

</div>

Hi all,

I upgraded a solution from Servoy 3 to Servoy 5.2.7 build 1013, and I’m experiencing a problem with a method creating and editing a record. The record gets created, but fields are not properly being set. For example a simple number field could get set to the value 5, if I evaluate the field in the Interactive console it shows a value of 5, but if I look at the back end data with a query browser the value of the field is 0. When the method completes, the servoy client then reverts to having a value of 0 for that field. It only holds it’s value while I’m debugging, and the backend never gets it.

I am using databaseManager.saveData() but it’s not saving. This wasn’t a problem in servoy 3. Does anyone know a trick to ensure that the data gets stored correctly in the backend?

Thanks

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [May 31, 2011, 8:55pm UTC](https://forum.servoy.com/t/data-not-pushed-to-mysql/14080/2 "2011-05-31T20:55:49Z")

</div>

Hi,

Does databaseManager.saveData() return true or false ?  
If false then Servoy can’t save the data. You can get the failed records and the error using the databaseManager.getFailedRecords() like so:

```auto
if (!databaseManager.saveData()) {
    var _aFailed = databaseManager.getFailedRecords();
    for (var i=0; i < _aFailed.length; i++) {
        Application.output('Error in save : ' + _aFailed[i].exception, LOGGINGLEVEL.ERROR);
    }
}

```

Hope this helps.

---

<div class="post-metadata">

**Author:** ![jkipling](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@jkipling](https://forum.servoy.com/u/jkipling)\
**Post date:** [June 1, 2011, 2:18pm UTC](https://forum.servoy.com/t/data-not-pushed-to-mysql/14080/3 "2011-06-01T14:18:43Z")

</div>

Thanks for the tip. It looks like databaseManager.saveData is returning true however, and the data is still not being committed in the MySQL backend.

It’s odd that the debugger evaluates a column to the value the method sets it too, but the Query Browser does not show this value.

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [June 1, 2011, 2:20pm UTC](https://forum.servoy.com/t/data-not-pushed-to-mysql/14080/4 "2011-06-01T14:20:16Z")

</div>

And do you use a database transaction perhaps ? Non committed data won’t show in other connections.

---

<div class="post-metadata">

**Author:** ![jkipling](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@jkipling](https://forum.servoy.com/u/jkipling)\
**Post date:** [June 1, 2011, 2:39pm UTC](https://forum.servoy.com/t/data-not-pushed-to-mysql/14080/5 "2011-06-01T14:39:43Z")

</div>

I am not using transactions.

I just said committed because I wasn’t sure how else to describe the situation where the column shows one value in the debugger and another in MySQL. And the value MySQL shows is the default value of the column, so it’s not like sometimes I am able to change the value of these columns. This is occurring for both number and text columns.

Thanks

---

<div class="post-metadata">

**Author:** ![jkipling](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@jkipling](https://forum.servoy.com/u/jkipling)\
**Post date:** [June 16, 2011, 6:13pm UTC](https://forum.servoy.com/t/data-not-pushed-to-mysql/14080/6 "2011-06-16T18:13:40Z")

</div>

Hi all,

This is still a big problem for me. I have some more info from more tests:

Right after creating the record I run databaseManager.saveData() and that returns true.

Then I store the primary key in a variable. The value of the variable is the correct primary key for the newest record that appears through a query browser.

Then I try performing a find using

```auto
 controller.find() ;
 pk_id = pk_variable;
controller.search();

```

which returns no records.

Then I try a query:

```auto
controller.loadRecords("SELECT pk_id FROM tableWHERE pk_id = " + pk_variable);

```

which also returns no records. So the record is created in the back end, but it cannot be modified by servoy, and it cannot be found by servoy. What’s going on here?

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [June 16, 2011, 6:24pm UTC](https://forum.servoy.com/t/data-not-pushed-to-mysql/14080/7 "2011-06-16T18:24:05Z")

</div>

Are you maybe using tableFilterparam?

---

<div class="post-metadata">

**Author:** ![jkipling](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@jkipling](https://forum.servoy.com/u/jkipling)\
**Post date:** [June 17, 2011, 9:58pm UTC](https://forum.servoy.com/t/data-not-pushed-to-mysql/14080/8 "2011-06-17T21:58:57Z")

</div>

Nope,

Here is the complete code I’m using. Something else to note, this method is being called by another method that is initiated from a form in a dialog. Could that have anything to do with it?

```auto
controller.newRecord(true);
var check = databaseManager.saveData();
var pk_var = pk_id;
//databaseManager.refreshRecordFromDatabase(-1);
//controller.find();
//pk_id = pk_var;
//controller.search();
controller.loadRecords("SELECT pk_id FROM table WHERE pk_id = " + pk_var);

return pk_var;

```

None of the commented out steps work. I am left with no records found after executing the controller.loadRecords step. Doing a find in the calling method doesn’t work either.

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [June 20, 2011, 9:18am UTC](https://forum.servoy.com/t/data-not-pushed-to-mysql/14080/9 "2011-06-20T09:18:53Z")

</div>

jkipling,

Does the log file show any errors?

Rob

---

<div class="post-metadata">

**Author:** ![jkipling](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@jkipling](https://forum.servoy.com/u/jkipling)\
**Post date:** [June 20, 2011, 11:50am UTC](https://forum.servoy.com/t/data-not-pushed-to-mysql/14080/10 "2011-06-20T11:50:56Z")

</div>

No errors.

---

<div class="post-metadata">

**Author:** ![sbutler](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/sbutler/32/4393_2.png) [@sbutler](https://forum.servoy.com/u/sbutler)\
**Post date:** [June 21, 2011, 1:15am UTC](https://forum.servoy.com/t/data-not-pushed-to-mysql/14080/11 "2011-06-21T01:15:34Z")

</div>

Did you accidentally make a new variable in your function, or a form variable, with the same name as a column in your table? If so, you would be confusing Servoy. like do you have a form variable called “pk\_id”?  
Also, what are you using for your table PK sequences? MySQL auto\_increment, or Servoy Sequences?

---

<div class="post-metadata">

**Author:** ![antonio](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@antonio](https://forum.servoy.com/u/antonio)\
**Post date:** [June 21, 2011, 4:34am UTC](https://forum.servoy.com/t/data-not-pushed-to-mysql/14080/12 "2011-06-21T04:34:16Z")

</div>

I’m seeing something similar, also in 5.2.7  
Invoices form has a related field from the patients table as a combobox. OnDataChange triggers a saveData() and then calls a headless client to do some stuff. However the HC does not always see the changes to the field.

---

<div class="post-metadata">

**Author:** ![jkipling](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@jkipling](https://forum.servoy.com/u/jkipling)\
**Post date:** [June 21, 2011, 11:23am UTC](https://forum.servoy.com/t/data-not-pushed-to-mysql/14080/13 "2011-06-21T11:23:46Z")

</div>

No, there are no variables named the same as a column.

I had this method that worked fine in 3, and now I’m doing everything I can to troubleshoot it in 5.2.7. I tried to find the record after it was saved and it is not found. If I clear the found set and then create the record, the interactive console shows the record, and its modified data but MySQL does not, and after the method completes servoy does not see it anymore.

This method is being called from a form in dialog, so I tried closing the dialog before creating the record, still no luck, however the method runs, other steps execute correctly, just not editing this one record. If I go to the form itself and manually create and edit the record, that works, it’s just this method that cannot edit the record.

I tired an SQL statement to find a record that was created in a previous attempt through it’s known pk\_id, and servoy does not find the record although it does show up in a query browser, but with only default values entered not the values entered by this method.

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [June 21, 2011, 12:46pm UTC](https://forum.servoy.com/t/data-not-pushed-to-mysql/14080/14 "2011-06-21T12:46:57Z")

</div>

oke, so you say, the record IS created directly in mySQL (dont use Servoy, but mySQL admin or something)

I still think you use somekind of tableFilterParam, or a foundsetFilter?? somehow, that’s why, Servoy filters it out…??

---

<div class="post-metadata">

**Author:** ![jkipling](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@jkipling](https://forum.servoy.com/u/jkipling)\
**Post date:** [June 21, 2011, 1:51pm UTC](https://forum.servoy.com/t/data-not-pushed-to-mysql/14080/15 "2011-06-21T13:51:22Z")

</div>

No the servoy method creates the record, if I look for it in MySQL, I see it, but it has only default values not the values set by the method.

That’s what’s odd, how can the record be created but not edited by servoy. And then furthermore, servoy cannot find the record.

It is not a privileges issue because the same user can manually edit records in this table.

By the way, the pk\_id has a sequence type of db identity

---

<div class="post-metadata">

**Author:** ![jkipling](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@jkipling](https://forum.servoy.com/u/jkipling)\
**Post date:** [June 21, 2011, 4:01pm UTC](https://forum.servoy.com/t/data-not-pushed-to-mysql/14080/16 "2011-06-21T16:01:56Z")

</div>

I just changed the pk column to use a servoy sequence instead of db identity and I had the same problem.

---

<div class="post-metadata">

**Author:** ![kurtbleicken](https://avatars.discourse-cdn.com/v4/letter/k/c57346/32.png) [@kurtbleicken](https://forum.servoy.com/u/kurtbleicken)\
**Post date:** [June 24, 2011, 1:53pm UTC](https://forum.servoy.com/t/data-not-pushed-to-mysql/14080/17 "2011-06-24T13:53:34Z")

</div>

I have a similar, but probably unrelated problem. In 5.2.7 in creating a child file in ‘assigned’ table from the parent ‘contacts’ table the child is created and populated with various fields including the assignee’s name. The assignee’s name is displayed in a contacts line item.

The name will appear after creation as several new assignments are being made. Then the name may not appear on the next assignment. The assignment after that it may appear correctly. Seems to be totally random whether or not the name will be rendered. However in the assigned table, in every case the child records are totally correct. When I log out of the solution and log back in, the assignee’s name appears every time on all records.

If I do a search on the assigned name when several assigned names are showing blank, the search result includes the records showing blank names.

I’ve tried DatabaseManager refreshRecordFromDatabase. No luck.

This problem did not appear in earlier versions of Servoy.

Any thoughts? K

using 5.2.7  
System 7  
Postgres  
Java 1.6.0\_24

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [June 27, 2011, 8:03am UTC](https://forum.servoy.com/t/data-not-pushed-to-mysql/14080/18 "2011-06-27T08:03:21Z")

</div>

jkipling, Kurt,

If you can reproduce this in a small sample, please file a case in our support system.

Rob

---

<div class="post-metadata">

**Author:** ![jkipling](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@jkipling](https://forum.servoy.com/u/jkipling)\
**Post date:** [July 5, 2011, 2:24pm UTC](https://forum.servoy.com/t/data-not-pushed-to-mysql/14080/19 "2011-07-05T14:24:32Z")

</div>

I have found a work around.

Even though I am editing this record through a form with a foundset and not through a relationship, there is a foreign key that needs to be populated before edits can stick. The method is not using any relationships based on this key and the column is allowed to be null, but for some reason it needs to be populated first before any other edits can stick. Again, this was not the case in Servoy 3. Pretty weird, but thanks for all the ideas everyone.
