DB2®ResultSet.CreateRecord Method

Creates a DB2UpdatableRecord instance to be used for the creation of a new row in the DB2ResultSet.

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

Syntax


[Visual Basic]
Public Function CreateRecord As DB2UpdatableRecord
[C#]
public DB2UpdatableRecord CreateRecord ()
[C++]
public:
DB2UpdatableRecord CreateRecord ()
[JScript]
public function CreateRecord () : DB2UpdatableRecord

Return value

A DB2UpdatableRecord instance.

Exceptions

Exception type Condition
InvalidOperationException An updatable cursor is required.

Remarks

Multiple DB2UpdatableRecord instances can be created and manipulated at the same time.

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;
  }