Is data saved in MySQL and Outsystems database?

Is data saved in MySQL and Outsystems database?

  

Hi!

I turn to the community for enlightenment! 


I have a connection created to a MySQL database and everything's ok and using Outsystems 10 Personal Environment.

This DB has 2 tables. Table 1 has the fields [ID1,Name] and Table 2 has the fields [ID2, FK_ID1, Name].

When testing a screen for creating a record for table 2, a missing validation (where FK_ID1 = 0) caused an error on saving a record.

Checking the MySQL DB table 2 was empty but if I made an aggregation in Outsystems, Table 2 showed having 1 record [1,0,test] .


So, my question is, when I save a record does it gets saved on both sides (MySQL and Outsystems)?

If so, whats the point on connecting to an external database?

If not, why did the aggreagtion had 1 record in it?


Thank you!

There are two databases, the OS database and the external database. If you create an entity using the external database table, the record should be saved in the external database, not in the OS database. 

Try to check again, whether you aggregate the correct entity or not?

regards,

bb

Hi Carlos,

Let me try to help with a couple of notes.

When you have an external database you don't actually create any new objects (tables) when you create entities in your app. Any entity you create in your app gets created in the OutSystems database, i.e. the database associated with you OutSystems environment.

If the table 2 is empty in MySQL (assuming you did a validation directly in the database on this single table) then there's no way the aggregate in OutSystems would show data on that table. Can you please add some screenshots that can help us understand what's happening?

Cheers

André Vieira wrote:

Hi Carlos,

Let me try to help with a couple of notes.

When you have an external database you don't actually create any new objects (tables) when you create entities in your app. Any entity you create in your app gets created in the OutSystems database, i.e. the database associated with you OutSystems environment.

If the table 2 is empty in MySQL (assuming you did a validation directly in the database on this single table) then there's no way the aggregate in OutSystems would show data on that table. Can you please add some screenshots that can help us understand what's happening?

Cheers

Hi André,


I've solved the problema by using a SQL Statement ( Delete from {Table2} ) that solved the issue and unfortunately I didn't take any screenshots.

I'll create a new app and try to reproduce the error and I'll post it here with oml included.


Thank you!


Hi André,


The same situation happened again.

I've saved a record, no error given, MySQL table has 0 records but aggregate shows the saved record.

Attached screenshots of the error that appear in the Service Center, the MySQL table result, the code flow that gave the message success and the aggregate result.


The screens were built using the scaffolding option of Outsystems.


Thank you,

Carlos



Hello,

Just to add some more info.

I've noticed that altough the records are being saved and are showing in the aggregations, nothing is saved in MySQL.

I've added some more exemples.



Hi Carlos,

Does the aggregate ever stop showing the information? If it does then please submit feedback from Service Studio.

What are you using to query MySQL directly? Is it possible that it is enforcing not to return rows that have empty FKs (I find this strange but...)


Regarding the errors, they happen because you are using the built-in Get<Entity> function, I believe in showing a label of a static entity, and you're passing null as an identifier which causes the function to throw an exception. Usually, you guard this code with an IF so that it doesn't execute the function when the FK is null.

André Vieira wrote:

Hi Carlos,

Does the aggregate ever stop showing the information? If it does then please submit feedback from Service Studio.

What are you using to query MySQL directly? Is it possible that it is enforcing not to return rows that have empty FKs (I find this strange but...)


Regarding the errors, they happen because you are using the built-in Get<Entity> function, I believe in showing a label of a static entity, and you're passing null as an identifier which causes the function to throw an exception. Usually, you guard this code with an IF so that it doesn't execute the function when the FK is null.

Hi André,


The label error I fixed after the initial debug. I was using the Get<Entity> function but I've made it so that no records with empty FK can be saved.


As for the rest:

  • the aggregations still show records that aren't saved in MySQL
  • the querys on the MySQL are made through cPanel, simple SELECT * FROM <Table>


To make some more tests:

  1.  I've created 2 new tables in the same DB. 
  2. Next I created a new database connecction in Service Center (connection test ok). 
  3. Creates a new app
  4. Add an extension with 2 entities with same fields as those in the DB.
  5. In the app created 2 screens to view the tables and 2 to edit records using the scaffolding method
  6. When going to view records from either table I get an error "Table doesn't exist"   


Why can't the platform see the new tables I've created?

Why does it keep saving in Outsystems when the tables are created in MySQL?


If you would like more detail you can contact me by PM.


Thanks,

Carlos




Hi Carlos,


Regarding your first question I'm not sure you used the Integration Studio to import the table definition and therefore if you did it manually, you might not have permissions to access that table with the user from the DB connection or you might have incomplete information. My suggestion is to use the wizard to import the foreign entities.

Besides this suggestion, I think you should submit a case to OutSystems Support to get this cleared out.


Cheers