ComponentOne DataObjects for .NET
IdentityColumnLastValueSelect Property

C1.Data.2 Assembly > C1.Data.SchemaObjects Namespace > SqlDialectInfo Class : IdentityColumnLastValueSelect Property
Gets or sets a string representing the SELECT command returning the last assigned identity (autoincrement) value in the current database connection.
Syntax
'Declaration
 
Public Property IdentityColumnLastValueSelect As System.String
public System.string IdentityColumnLastValueSelect {get; set;}
Remarks
Implementing autoincrement functionality on adding a row for a field with AutoIncrement = ClientAndServer, C1DataObjects tries to retrieve the autoincrement (identity) values assigned by the database to the field, in order to refresh that value on the client. If your database supports retrieving the last assigned identity value via a single command, you can set this property to a command string retrieving that value. That will be enough for C1DataObjects to implement the autoincrement refresh functionality.

This property is used in conjunction with the IdentityColumnRetrieveMode property. By default, C1DataObjects sets correct values for well-known databases such as SQL Server, MS Access, Oracle, Interbase. For example, in SQL Server 2000, this command is "SELECT SCOPE_IDENTITY()" and IdentityColumnRetrieveMode is InInsertCommand. In Microsoft Access, this command is "SELECT @@IDENTITY" and the IdentityColumnRetrieveMode is AfterInsertCommand.

In Oracle and Interbase, there are two options:

If you need a trigger setting the autoincrement key value on INSERT, use IdentityColumnRetrieveMode = AfterInsertCommand and the following properties for Oracle and Interbase:

Oracle: set IdentityColumnLastValueSelect = SELECT AUTOINCREMENTSEQUENCENAME.CURRVAL FROM DUAL and set the AutoIncrementSequenceName field property to the corresponding sequence name.

Interbase: set IdentityColumnLastValueSelect = SELECT GEN_ID(AUTOINCREMENTSEQUENCENAME, 0) FROM RDB$DATABASE and set the AutoIncrementSequenceName field property to the corresponding generator name.

Without such trigger, set the IdentityColumnRetrieveMode = BeforeInsertCommand and the following properties for Oracle and Interbase:

Oracle: set IdentityColumnLastValueSelect = SELECT AUTOINCREMENTSEQUENCENAME.NEXTVAL FROM DUAL and set the AutoIncrementSequenceName field property to the corresponding sequence name.

Interbase: set IdentityColumnLastValueSelect = SELECT GEN_ID(AUTOINCREMENTSEQUENCENAME, 1) FROM RDB$DATABASE and set the AutoIncrementSequenceName field property to the corresponding generator name.

If your database does not support this functionality, you still can implement refreshing autoincrement value in AutoIncrement = ClientAndServer writing code in AfterUpdateRow event as shown in Keys Assigned by Server or Database.

See Also

Reference

SqlDialectInfo Class
SqlDialectInfo Members
Keys Assigned by Server or Database