IT tutorials
 
Technology
 

Microsoft Dynamic AX 2009 : .Performance (part 3) - Transaction Performance - Set-Based Data Manipulation Operators - The update_recordset Operator

10/28/2013 3:35:13 AM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
The update_recordset Operator

The behavior of the update_recordset operator is very similar to that of the insert_recordset operator. This similarity is illustrated by the following piece of X++ code, in which all sizes for an item are updated with a new description.

static void UpdateSizes(Args _args)
{
InventSize inventSize;
;
ttsbegin;
update_recordset inventSize
setting Description = 'This size is for item 1000'
where inventSize.itemId == '1000';
ttscommit;
}


The execution of update_recordset results in one statement being parsed to the database, which in SQL Server uses a syntax similar to UPDATE <table> <SET> <field and expression list> WHERE <predicates>. As with insert_recordset, update_recordset provides a tremendous improvement in performance over the record-based version, in which each record is updated individually. This improvement is shown in the following X++ code, which serves the same purpose as the preceding example. The code selects all the records qualified for update, sets the new description value, and updates the record.

static void UpdateSizes(Args _args)
{
InventSize inventSize;
;
ttsbegin;
while select forupdate inventSize
where inventSize.itemId == '1000'
{
inventSize.Description = 'This size is for item 1000';
inventSize.update();
}
ttscommit;
}


If 10 records qualified, 1 select statement and 10 update statements would be parsed to the database rather than the single update statement that would be parsed if you used update_recordset.

The update_recordset operation can be downgraded if specific methods have been overridden or the the Dynamics AX application is configured. The update_recordset operation is downgraded if any of the following conditions is true:

  • The table is entire-table cached.

  • The update method, the aosValidateUpdate method, or the aosValidateRead method is overridden on the target table.

  • Alerts have been set up to be triggered by update queries into the target table.

  • The database log has been configured to log update queries into the target table.

  • RLS is enabled on the target table.

The Dynamics AX application runtime automatically handles the downgrade and internally executes a scenario similar to the while select scenario shown in the preceding example.

You can avoid any downgrade caused by the previously mentioned functionality unless the table is entire-table cached. The record buffer contains methods that turn off the checks that the application runtime performs when determining whether to downgrade the update_recordset operation.

  • Calling skipDataMethods(true) prevents the check that determines whether the update method is overridden.

  • Calling skipAosValidation(true) prevents the checks on the aosValidateUpdate and aosValidateRead methods.

  • Calling skipDatabaseLog(true) prevents the check that determines whether the database log is configured to log updates to records in the table.

  • Calling skipEvents(true) prevents the check to determine whether any alerts have been set to be triggered by the update event on the table.

As we explained earlier, you should use the skip methods with great caution, and you should take the same precautions before using the skip methods in combination with the update_recordset operation. Again, using the skip methods only influences whether the update_recordset operation is downgraded to a while select scenario. If the operation is downgraded, database logging, alerting, and execution of overridden methods occurs even though the respective skip methods have been called.

Tip

If an update_recordset operation is downgraded to a while select scenario, the select statement uses the concurrency model specified at the table level. You can apply the optimisticlock and pessimisticlock keywords to the update_recordset statements and enforce a specific concurrency model to be used in case of downgrade.


Dynamics AX 2009 supports inner and outer joins in update_recordset. Previous versions of Dynamics AX supported only exists and not exists joins. The support for joins in update_recordset enables an application to perform set-based operations when the source data is fetched from more than one related Data Source.

The following example illustrates the usage of joins with update_recordset.

static void UpdateRecordsetJoinsExample(Args _args)
{
NewTaxes taxTable;
Orders ordersTable;
;
ttsbegin;
UPDATE_RECORDSET
ordersTable
SETTING
Total = ordersTable.Total + ( ordersTable.Total * ( taxTable.TaxPercent / 100 ) )
JOIN
taxTable
WHERE
ordersTable.CountryId == taxTable.CountryId
;
ttscommit;
}

 
Others
 
- Microsoft Dynamic AX 2009 : .Performance (part 2) - Transaction Performance - Set-Based Data Manipulation Operators - The insert_recordset Operator
- Microsoft Dynamic AX 2009 : .Performance (part 1) - Reducing Round-Trips Between the Client and the Server
- Exchange Server 2010 Quick Start Guide : Configuring Recipients (part 3) - Configuring a Postmaster Address, SSL Certificate , Entering the Product Key
- Exchange Server 2010 Quick Start Guide : Configuring Recipients (part 2) - Creating Distribution Groups, Organizational Health
- Exchange Server 2010 Quick Start Guide : Configuring Recipients (part 1)
- Sharepoint 2010 : Data Access Overview - Performance
- Sharepoint 2010 : Data Access Overview - Lists and Document Libraries
- Sharepoint 2010 : Data Access Overview - Columns (part 3) - Field Types - Inheriting from BaseFieldControl
- Sharepoint 2010 : Data Access Overview - Columns (part 2) - Field Types - Inheriting from SPField
- Sharepoint 2010 : Data Access Overview - Columns (part 1)
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us