The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Class::DBI::MSSQL - Class::DBI for MSSQL

VERSION

version 0.01_01

 $Id: MSSQL.pm,v 1.5 2004/09/07 16:39:45 rsignes Exp $

SYNOPSIS

        use base qw(Class::DBI::MSSQL);

        # lots of normal-looking CDBI code

DESCRIPTION

This is just a simple subclass of Class::DBI; it makes Class::DBI play nicely with MSSQL, at least if DBD::ODBC is providing the connection.

Here are the things it changes:

  • use SELECT @@IDENTITY to get last autonumber value

  • use INSERT INTO table DEFAULT VALUES for create({})

WARNINGS

For one thing, there are no useful tests in this distribution. I'll take care of that, but right now this is all taken care of in the tests I've written for subclasses of this class, and I don't have a lot of motivation to write new tests just for this package.

Class::DBI's _init sub has a line that reads as follows:

 if (@primary_columns == grep defined, @{$data}{@primary_columns}) {     

This will break MSSQL, and the line must be changed to:

 if (@$data{@primary_columns}
        and @primary_columns == grep defined, @{$data}{@primary_columns}
 ) {

I can't easily subclass that routine, as it relies on lexical variables above its scope. I've sent a patch to Tony, which I expect to be in the next Class::DBI release.

THANKS

...to Michael Schwern and Tony Bowden for creating and maintaining, respectively, the excellent Class::DBI system.

...to Casey West, for his crash course on Class::DBI at OSCON '04, which finally convinced me to just use the darn thing.

AUTHOR

Ricardo SIGNES, <rjbs@cpan.org>

COPYRIGHT

(C) 2004, Ricardo SIGNES. Class::DBI::MSSQL is available under the same terms as Perl itself.