dotConnect for PostgreSQL Documentation
Devart.Data.PostgreSql Namespace / PgSqlCommand Class / InsertOid Property
Example

InsertOid Property
Returns the object ID generated for an OID column by the previous insert command.
Syntax
'Declaration
 
Public ReadOnly Property InsertOid As Long
 

Property Value

The ID generated for an OID column.
Remarks
Use InsertOid property after you have performed an INSERT command into a table.

If the command doesn't perform an insertion into a table the value of InsertOid won't be defined.

Example
After running the query the value assigned to OID column for the inserted record is shown.
static void GetLastId(PgSqlConnection pgConnection)
{
  PgSqlCommand pgCommand = new PgSqlCommand("INSERT INTO Test.Dept (DeptNo, DName, Loc) VALUES (Null, 'AnotherOne', 'SomeWhere')", pgConnection);
  pgConnection.Open();
  try
  {
    pgCommand.ExecuteNonQuery();
    Console.WriteLine(pgCommand.InsertOid);
  }
  finally
  {
    pgConnection.Close();
  }
}
Public Sub GetLastId(ByVal pgConnection As PgSqlConnection)
  Dim pgCommand As New PgSqlCommand("INSERT INTO Test.Dept (DeptNo, DName, Loc) VALUES (Null, 'AnotherOne', 'SomeWhere')", pgConnection)
  pgConnection.Open()
  Try
    pgCommand.ExecuteNonQuery()
    Console.WriteLine(pgCommand.InsertOid)
  Finally
    pgConnection.Close()
  End Try
End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also