Jan 9, 2012

How to insert and update a record into a table?


Following example inserts a new record into the MyTable table, with the AccountNum set to 1000 and the Name set to MyName (other fields in the record will be blank).

MyTable  MyTable
;
ttsBegin;

select MyTable ;
MyTable.AccountNum = '1000';
MyTable.Name = 'MyName';
MyTable.insert();
  
ttsCommit;

Following example updates the record in the MyTable table  with the AccountNum  1000 ,AccountNum set 1000 to "100012" and  the Name set MyName to NewName 
MyTable  MyTable
;
ttsBegin;
  
select forUpdate MyTable where MyTable.AccountNum = "1000";
 ;
MyTable.AccountNum = '100012';
MyTable.Name = 'NewName';
MyTable.update();
  
ttsCommit;

No comments: