1 package DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server;
7 DBIx::Class::Storage::DBI::Sybase
8 DBIx::Class::Storage::DBI::MSSQL
12 use Carp::Clan qw/^DBIx::Class/;
15 __PACKAGE__->datetime_parser_type(
16 'DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::DateTime::Format'
21 my $dbh = $self->_get_dbh;
23 return if ref $self ne __PACKAGE__;
24 if (not $self->_use_typeless_placeholders) {
26 DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars;
28 'DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars';
33 sub _run_connection_actions {
36 # LongReadLen doesn't work with MSSQL through DBD::Sybase, and the default is
37 # huge on some versions of SQL server and can cause memory problems, so we
38 # fix it up here (see ::DBI::Sybase.pm)
41 $self->next::method(@_);
47 $self->_get_dbh->do('BEGIN TRAN');
53 or $self->throw_exception('cannot COMMIT on a disconnected handle');
60 or $self->throw_exception('cannot ROLLBACK on a disconnected handle');
64 sub _get_server_version {
67 my $product_version = $self->_get_dbh->selectrow_hashref('master.dbo.xp_msver ProductVersion');
69 if ((my $version = $product_version->{Character_Value}) =~ /^(\d+)\./) {
73 $self->throw_exception(
74 "MSSQL Version Retrieval Failed, Your ProductVersion's Character_Value is missing or malformed!"
79 =head2 connect_call_datetime_setup
83 on_connect_call => 'datetime_setup'
85 In L<connect_info|DBIx::Class::Storage::DBI/connect_info> to set:
87 $dbh->syb_date_fmt('ISO_strict'); # output fmt: 2004-08-21T14:36:48.080Z
89 On connection for use with L<DBIx::Class::InflateColumn::DateTime>
91 This works for both C<DATETIME> and C<SMALLDATETIME> columns, although
92 C<SMALLDATETIME> columns only have minute precision.
97 my $old_dbd_warned = 0;
99 sub connect_call_datetime_setup {
101 my $dbh = $self->_get_dbh;
103 if ($dbh->can('syb_date_fmt')) {
104 # amazingly, this works with FreeTDS
105 $dbh->syb_date_fmt('ISO_strict');
106 } elsif (not $old_dbd_warned) {
107 carp "Your DBD::Sybase is too old to support ".
108 "DBIx::Class::InflateColumn::DateTime, please upgrade!";
115 package # hide from PAUSE
116 DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::DateTime::Format;
118 my $datetime_parse_format = '%Y-%m-%dT%H:%M:%S.%3NZ';
119 my $datetime_format_format = '%Y-%m-%d %H:%M:%S.%3N'; # %F %T
121 my ($datetime_parser, $datetime_formatter);
125 require DateTime::Format::Strptime;
126 $datetime_parser ||= DateTime::Format::Strptime->new(
127 pattern => $datetime_parse_format,
130 return $datetime_parser->parse_datetime(shift);
133 sub format_datetime {
135 require DateTime::Format::Strptime;
136 $datetime_formatter ||= DateTime::Format::Strptime->new(
137 pattern => $datetime_format_format,
140 return $datetime_formatter->format_datetime(shift);
147 DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server - Support for Microsoft
148 SQL Server via DBD::Sybase
152 This subclass supports MSSQL server connections via L<DBD::Sybase>.
156 This driver tries to determine whether your version of L<DBD::Sybase> and
157 supporting libraries (usually FreeTDS) support using placeholders, if not the
158 storage will be reblessed to
159 L<DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars>.
161 The MSSQL specific functionality is provided by
162 L<DBIx::Class::Storage::DBI::MSSQL>.
166 See L<DBIx::Class/CONTRIBUTORS>.
170 You may distribute this code under the same terms as Perl itself.