Why not adopt me?
NAME
Class::DBI::MSSQL - Class::DBI for MSSQL
VERSION
version 0.10
$Id: MSSQL.pm,v 1.7 2004/09/22 11:35:38 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 valueuse
INSERT INTO table DEFAULT VALUES
forcreate({})
It also implements some metadata methods, described below.
METHODS
set_up_table($table_name)
This method sets up the columns from the named table by querying MSSQL's information_schema
metadata tables. It will set up the key(s) as Primary and all other columns as Essential.
column_type($column_name)
This returns the named column's datatype.
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 James O'Sullivan, for graciously sending me his own solution to this problem, which I've happily included.
...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
>
set_up_table
and column_type
from James O'Sullivan.
COPYRIGHT
(C) 2004, Ricardo SIGNES. Class::DBI::MSSQL is available under the same terms as Perl itself.