DB2®ResultSet.Insert Method

Inserts a new row into the result set, and its corresponding table.

Namespace:
IBM.Data.DB2
Assembly:
IBM.Data.DB2 (in IBM.Data.DB2.dll)

Syntax


[Visual Basic]
Public Sub Insert (updatableRecord As DB2UpdatableRecord)
[C#]
public void Insert (DB2UpdatableRecord updatableRecord)
[C++]
public:
void Insert (DB2UpdatableRecord* updatableRecord)
[JScript]
public function Insert (updatableRecord: DB2UpdatableRecord)

Parameters

updatableRecord
A DB2UpdatableRecord instance, representing a new row to be inserted into the result set.

Remarks

A DB2UpdatableRecord instance can only be inserted by the DB2ResultSet instance that created it.

The cursor position of the DB2ResultSet instance does not change upon insertion of the new row.

Example

[C#] The following example demonstrates how to insert a new row into a DB2ResultSet instance, provided the server supports updatable cursors.

[C#]
  public static void insertSalesData(DB2Connection conn)
  {
    string salesQuery = "SELECT * FROM SALES";
    string salesData = "";
    DB2Command cmd = new DB2Command(salesQuery, conn);
    DB2ResultSet salesRS = cmd.ExecuteResultSet(
      DB2ResultSetOptions.Scrollable |
      DB2ResultSetOptions.Sensitive |
      DB2ResultSetOptions.SkipDeleted |
      DB2ResultSetOptions.Updatable);

    if (salesRS.Updatable)
    {
      DB2UpdatableRecord updatableSale = salesRS.CreateRecord();
      updatableSale.SetDB2Date(0, new DB2Date(DateTime.Now));
      updatableSale.SetDB2String(1, new DB2String("Erik"));
      updatableSale.SetDB2String(2, new DB2String( "Ontario-South"));
      updatableSale.SetDB2Int32(3, new DB2Int32(2));

      salesRS.Insert(updatableSale);
    }

    return;
  }