Using a temporary table
Temporary tables can be useful when you need to insert data into a table to perform calculations but don't want it saved to the database. This recipe will show you how to mark your records as temporary and what to watch out for when you do so.
How to do it...
Create a new codeunit with Object Designer.
Add the following global variables:
Name
Type
Subtype
Customer
Record
Customer
TempCustomer
Record
Customer
With the cursor hovering over the
Tempcustomer
variable, click on Properties in the View menu or press Shift + F4.Set the following property:
Property
Value
Temporary
Yes
Write the following code into the
OnRun
trigger of the codeunit:MESSAGE('Customer Count: %1\TempCustomer Count: %2', Customer.COUNT, TempCustomer.COUNT);
Save and close the codeunit.
On executing the codeunit, you should see a window similar to the one in the following screenshot:
How it works...
Declaring a record variable as temporary is as easy as setting...