data not pushed to MySQL

Questions, tips and tricks and techniques for scripting in Servoy

data not pushed to MySQL

Postby jkipling » Tue May 31, 2011 10:47 pm

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
jkipling
 
Posts: 99
Joined: Tue Nov 20, 2007 7:46 pm
Location: Natick, MA

Re: data not pushed to MySQL

Postby ROCLASI » Tue May 31, 2011 10:55 pm

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:
Code: Select all
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.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: data not pushed to MySQL

Postby jkipling » Wed Jun 01, 2011 4:18 pm

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.
jkipling
 
Posts: 99
Joined: Tue Nov 20, 2007 7:46 pm
Location: Natick, MA

Re: data not pushed to MySQL

Postby ROCLASI » Wed Jun 01, 2011 4:20 pm

And do you use a database transaction perhaps ? Non committed data won't show in other connections.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: data not pushed to MySQL

Postby jkipling » Wed Jun 01, 2011 4:39 pm

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
jkipling
 
Posts: 99
Joined: Tue Nov 20, 2007 7:46 pm
Location: Natick, MA

Re: data not pushed to MySQL

Postby jkipling » Thu Jun 16, 2011 8:13 pm

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
Code: Select all
controller.find() ;
pk_id = pk_variable;
controller.search();


which returns no records.

Then I try a query:
Code: Select all
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?
jkipling
 
Posts: 99
Joined: Tue Nov 20, 2007 7:46 pm
Location: Natick, MA

Re: data not pushed to MySQL

Postby Harjo » Thu Jun 16, 2011 8:24 pm

Are you maybe using tableFilterparam?
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: data not pushed to MySQL

Postby jkipling » Fri Jun 17, 2011 11:58 pm

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?

Code: Select all

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.
jkipling
 
Posts: 99
Joined: Tue Nov 20, 2007 7:46 pm
Location: Natick, MA

Re: data not pushed to MySQL

Postby rgansevles » Mon Jun 20, 2011 11:18 am

jkipling,

Does the log file show any errors?

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1927
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Re: data not pushed to MySQL

Postby jkipling » Mon Jun 20, 2011 1:50 pm

No errors.
jkipling
 
Posts: 99
Joined: Tue Nov 20, 2007 7:46 pm
Location: Natick, MA

Re: data not pushed to MySQL

Postby sbutler » Tue Jun 21, 2011 3:15 am

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?
Scott Butler
iTech Professionals, Inc.
SAN Partner

Servoy Consulting & Development
Servoy University- Training Videos
Servoy Components- Plugins, Beans, and Web Components
Servoy Guy- Tips & Resources
ServoyForge- Open Source Components
User avatar
sbutler
Servoy Expert
 
Posts: 759
Joined: Sun Jan 08, 2006 7:15 am
Location: Cincinnati, OH

Re: data not pushed to MySQL

Postby antonio » Tue Jun 21, 2011 6:34 am

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.
Tony
Servoy 8 - 2022.03 LTS
antonio
 
Posts: 638
Joined: Sun Apr 02, 2006 2:14 am
Location: Australia

Re: data not pushed to MySQL

Postby jkipling » Tue Jun 21, 2011 1:23 pm

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.
jkipling
 
Posts: 99
Joined: Tue Nov 20, 2007 7:46 pm
Location: Natick, MA

Re: data not pushed to MySQL

Postby Harjo » Tue Jun 21, 2011 2:46 pm

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...??
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: data not pushed to MySQL

Postby jkipling » Tue Jun 21, 2011 3:51 pm

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
jkipling
 
Posts: 99
Joined: Tue Nov 20, 2007 7:46 pm
Location: Natick, MA

Next

Return to Methods

Who is online

Users browsing this forum: No registered users and 11 guests