Data Providers
Microsoft Azure SQL
Update a customer (UPDATE)
8min
Scenario
This example uses a default jig with a form that executes an SQL command to update a customer record.
Resources
Jigx Code
The Azure SQL Docs solution is on GitHub.
Update customer
- The execute-entity action allows you to specify the function parameters and their values, as well as the data properties for the SQLite table. You have more granular control over the values being saved and can include expressions. The example below uses an execute- entity action and maps both the parameters of the function and the SQLite data in the action's configuration.
- To improve the user experience, data displayed after it has been created or updated should be updated in the local SQLite database and the backend SQL system at the same action.
- If the data is only submitted to the backend system, it must be synced back to the device before the local tables are updated, and the information can be displayed. This can cause a significant lag and latency in the user's experience.
- The example below updates the data in Azure SQL and the SQLite database on the device when the user presses the Save button. This is the best practice for building responsive user experiences when working with remote data. See the Data lifecycles in Jigx section of the documentation for a detailed explanation.
The stored procedure was designed to create a new record in Azure SQL if no matching id is found. If the id already exists, the Azure SQL record is updated. The same stored procedure is used for creating a new customer and updating a customer.
The SQL query version of create-customer.jigx below only creates a new record. It does not contain update like like the stored procedure above. The only reason for this difference is to provide an alternative example and SQL logic.
- Use an execute-entity action to submit the values of the components to the function to update Azure SQL and to save the new customer to the local SQLite database.
- When the execute-entity action type is used to save the values of the controls on a form, the form is unaware of the saved state, and isDiscardChangesAlertEnabled needs to be set to false to avoid seeing the dialog even when data has been saved.
- Set the components on the form's value properties to the values from the mydata data source to display the existing values of the customer.
Updated 21 May 2024
Did this page help you?