Datapump code changes that affect Engineering
- Last UpdatedApr 24, 2025
- 2 minute read
In the upgrade to Microsoft SQL Server practice, the code in Historical related product components was modified to use TOP instead of SET ROWCOUNT. Only a few places in the datapump code still use SET ROWCOUNT. Below, the datapump code is used as an example to illustrate what was done in the code.
There is a function called SetRowCount in the DPMSCount.cpp file. It is implemented from the virtual function SetRowCount in DPConnection.h. This function executes the SET ROWCOUNT command in Microsoft SQL server. This function was not removed from the code because it may be used by the project in their application or custom code. However comments were added in the beginning of the function to warn you to use it carefully.

Since this function executes the SET ROWCOUNT command, any code that calls this function can set its own row count and the SELECT, INSERT, UPDATE, and DELETE statements that follow this function call will be affected. The following changes were made to the code:
-
All the query statements between SetRowCount(numRows) and SetRowCount(0), which set the row count and re-set the row count, were analyzed. TOP was added to each statement and the where clause was modified if it was required.
-
The function call to SetRowCount() was removed.
For example, the following code changes were made to DPdatapump.cpp. The function int DPdatapump::DoUpdate(TFlexString& fieldStr, const char *sys) contained the following code:
pSrc->SetRowCount(1);
stmt = "";
stmt << "update xosapp..datapump set " << fieldStr << where;
int err = pSrc->ExecSQL(stmt.Get());
pSrc->SetRowCount(0);
This code was removed and replaced with the following code:
stmt = "";
stmt << "update top (1) xosapp..datapump set " << fieldStr << where;
int err = pSrc->ExecSQL(stmt.Get());
Projects should perform the same modifications to all of the code in Datapump that calls the function SetRowCount().
Exception in DPUtil.cpp
There is one exception in Datapump code that still uses the SetRowCount() function; it is in the DPUtil.cpp file.

Within the above function, SetRowCount() is called to set the row count to 1000. Since there are only SELECT statements and the DPFill calls follow the SetRowCount(1000) and they only insert one row into the key table, there should be no problem to leave the code unchanged.
In the future, any INSERT, DELETE, or UPDATE statements added to this function should use TOP. If the project has modified this function in its custom code, this function should be revisited to make sure that the deprecated function is not used.