DBIx::Class::Storage::DBI::MSSQL - Base Class for Microsoft SQL Server support in DBIx::Class
This is the base class for Microsoft SQL Server support, used by DBIx::Class::Storage::DBI::ODBC::Microsoft_SQL_Server and DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server.
Microsoft SQL Server supports three methods of retrieving the IDENTITY value for inserted row: IDENT_CURRENT, @@IDENTITY, and SCOPE_IDENTITY(). SCOPE_IDENTITY is used here because it is the safest. However, it must be called is the same execute statement, not just the same connection.
So, this implementation appends a SELECT SCOPE_IDENTITY() statement onto each INSERT to accommodate that requirement.
SELECT @@IDENTITY can also be used by issuing:
SELECT @@IDENTITY
$self->_identity_method('@@identity');
it will only be used if SCOPE_IDENTITY() fails.
This is more dangerous, as inserting into a table with an on insert trigger that inserts into another table with an identity will give erroneous results on recent versions of SQL Server.
See "CONTRIBUTORS" in DBIx::Class.
You may distribute this code under the same terms as Perl itself.
To install DBIx::Class, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Class
CPAN shell
perl -MCPAN -e shell install DBIx::Class
For more information on module installation, please visit the detailed CPAN module installation guide.