Wednesday, July 4, 2018

Data Manipulation "Update"

The Update command modifies existing data in a table with the contents of a
table buffer. The record is first retrieved from the database using a select
statement. The data is then modified by assigning the new values to the fields in
the table buffer. The new values are then committed to the database using the
update() method.
Before records can be updated, use
select forUpdate to exclusively set a record
for update. This tells SQL that the record is to be updated and allows the database
to lock the record so that another user cannot modify it at the same time.
The following example updates the customer name on all sales orders for the
customer with the account number 2001



1
2
3
4
5
6
7
8
9
SalesTable salesTable;
ttsbegin;
while select forupdate salesTable
where salesTable.CustAccount =="2001"
{
  salesTable.SalesName ="New Enterprises";
  salesTable.update();
}
ttscommit;

NOTE: The use of ttsbegin and ttscommit. This indicates the start and end of a
transaction. This topic will be discussed at the end of this section.


Best Regards,
Hossein Karimi

No comments:

Post a Comment

Configure the Firewall on the Enterprise Portal Server

After you install Enterprise Portal, enable Web Server (HTTP) in Windows Firewall. If you do not enable the web server in Windows Firewall...