1 package DBIx::Class::Storage::DBI::IdentityInsert;
5 use base 'DBIx::Class::Storage::DBI';
12 DBIx::Class::Storage::DBI::IdentityInsert - Storage Component for Sybase ASE and
13 MSSQL for Identity Inserts / Updates
17 This is a storage component for Sybase ASE
18 (L<DBIx::Class::Storage::DBI::Sybase::ASE>) and Microsoft SQL Server
19 (L<DBIx::Class::Storage::DBI::MSSQL>) to support identity inserts, that is
20 inserts of explicit values into C<IDENTITY> columns.
22 This is done by wrapping C<INSERT> operations in a pair of table identity
25 SET IDENTITY_INSERT $table ON
27 SET IDENTITY_INSERT $table OFF
31 # SET IDENTITY_X only works as part of a statement scope. We can not
32 # $dbh->do the $sql and the wrapping set()s individualy. Hence the
33 # sql mangling. The newlines are important.
34 sub _prep_for_execute {
37 return $self->next::method(@_) unless $self->_autoinc_supplied_for_op;
39 my ($op, $ident) = @_;
41 my $table = $self->sql_maker->_quote($ident->name);
44 my ($sql, $bind) = $self->next::method(@_);
46 return (<<EOS, $bind);
47 SET IDENTITY_$op $table ON
49 SET IDENTITY_$op $table OFF
56 See L<DBIx::Class/AUTHOR> and L<DBIx::Class/CONTRIBUTORS>.
60 You may distribute this code under the same terms as Perl itself.