Working with tables and writing to database

Hi All

Anothe question. I have a table that is linked to a data via a query. When a user makes a change to the data (in this case set a value as active/inactive), I would like to push the change to the database. I’m wondering which method is better and how to do either.

Method 1: On change run an update statement (On each change write)

Method 2: Bank changes and have them click a “save” button

I have found how to do this via a button, but think that in in-table editor will be a lot quicker/easier.

Thanks S

Is this vison or perspective?

Both the methods are valid. It total depends on what you want to do, sometimes you only have one record to update, in that case you just reference the rowid that you want to update on your database table and run a update named query just for that row.

Othertimes, you might want to make multiple updates in different rows, then you need to go for the Method 2 and save all updated records to the database on click of a "save" button.

I strongly prefer method 2. And I generally arrange to highlight table cells that have changes.

Thanks, I'm leaning towards method 2 as it minimises writes.

Is there any guidance you can provide on how to link the table correctly and then how the save function would work to grab the data? When I bind it, it doesn't seems to want to allow me to change values.

I recommend a named query binding (dataset mode, no polling) to a custom property, not directly to the table's props.data. Use a unidirectional binding to a second custom property that will hold modified data as you go. (The unidirectional binding will clear changes when you make the named query refresh.)

Use a property binding on props.data with a script transform, or perhaps an expression binding with my toolkit's iterators, to capture changes to the 2nd custom prop, and add highlighting for cells that do not match between custom props.

Your table handling of changes would write to the 2nd custom prop. The save button would iterate through the 2nd custom prop, comparing to the first, to generate SQL updates. After all SQL updates, it would refresh the custom prop with the named query binding.

1 Like