Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA Enterprise SCADA High Performance Database (HPDB) API Reference

Update a record

This scenario guides you through the steps required to update an analog record in the RealTime database (RTDB).

To identify the code associated with each step, see the code comments in the Example code section.

To update a record

  1. Open the Program.cs file from the created project.
  2. Open the RTDB.
  3. Access the analog table.
  4. Lock the analog table for reading.
  5. Lock the record for writing.
  6. Write the description field by using one of the following methods:
    • Using the record number, if known.

      using (IRealTimeRecord record = new RealTimeRecord(table))
       {
           record.BindRecordNumber(28);
           record.Lock(recordLockRequest.SAFE_WRITE);
           record.WriteField<String>("description", "AnalogPoint_1 desc updated");
       }
    • Getting the record by name.

      var nameField = new RealTimeStringField(table, "name");
      using (IRealTimeRecord record = table.FindRecord(nameField, "AnalogPoint_1"))
      {                      
          record.Lock(recordLockRequest.SAFE_WRITE);
          record.WriteField<String>("description", "AnalogPoint_1 desc updated");
      }
  7. Unlock the record.
  8. Unlock the analog table.

Example code

IRealTimeDatabase database = new RealTimeDatabase();
try
{
    // Open the RTDB.
    if (!database.IsOpen())
    {
        database.Open();
    }
 
    // Access the analog table.
    using (IRealTimeTable table = new RealTimeTable("analog"))
    {
        ITableLockRequestType tableLockRequest = new TableLockRequestType();
        IRecordLockRequestType recordLockRequest = new RecordLockRequestType();
        // Lock the analog table for reading.        
        table.Lock(tableLockRequest.SAFE_READ);
     
        // Write the description field.
        var nameField = new RealTimeStringField(table, "name");
        using (IRealTimeRecord record = table.FindRecord(nameField, "AnalogPoint_1"))
        {    
            // Lock the record for writing.                  
            record.Lock(recordLockRequest.SAFE_WRITE);
            record.WriteField<String>("description", "AnalogPoint_1 desc updated");
         } // Leaving scope releases the record lock.
    } // Leaving scope releases the analog table lock.
}
catch (Exception ex)
{
    Console.WriteLine(
quot;Error updating a record:
{ex.Message}"); }
TitleResults for “How to create a CRG?”Also Available in