1 package DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server;
7 DBIx::Class::Storage::DBI::Sybase
8 DBIx::Class::Storage::DBI::MSSQL
11 use Carp::Clan qw/^DBIx::Class/;
15 my $dbh = $self->_get_dbh;
17 return if ref $self ne __PACKAGE__;
18 if (not $self->_use_typeless_placeholders) {
20 DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars;
22 'DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars';
27 sub _run_connection_actions {
30 # LongReadLen doesn't work with MSSQL through DBD::Sybase, and the default is
31 # huge on some versions of SQL server and can cause memory problems, so we
32 # fix it up here (see ::DBI::Sybase.pm)
35 $self->next::method(@_);
41 $self->_get_dbh->do('BEGIN TRAN');
47 or $self->throw_exception('cannot COMMIT on a disconnected handle');
54 or $self->throw_exception('cannot ROLLBACK on a disconnected handle');
58 sub _get_server_version {
61 my $product_version = $self->_get_dbh->selectrow_hashref('master.dbo.xp_msver ProductVersion');
63 if ((my $version = $product_version->{Character_Value}) =~ /^(\d+)\./) {
67 $self->throw_exception(
68 "MSSQL Version Retrieval Failed, Your ProductVersion's Character_Value is missing or malformed!"
73 =head2 connect_call_datetime_setup
77 on_connect_call => 'datetime_setup'
79 In L<connect_info|DBIx::Class::Storage::DBI/connect_info> to set:
81 $dbh->syb_date_fmt('ISO_strict'); # output fmt: 2004-08-21T14:36:48.080Z
83 On connection for use with L<DBIx::Class::InflateColumn::DateTime>
85 This works for both C<DATETIME> and C<SMALLDATETIME> columns, although
86 C<SMALLDATETIME> columns only have minute precision.
91 my $old_dbd_warned = 0;
93 sub connect_call_datetime_setup {
95 my $dbh = $self->_get_dbh;
97 if ($dbh->can('syb_date_fmt')) {
98 # amazingly, this works with FreeTDS
99 $dbh->syb_date_fmt('ISO_strict');
100 } elsif (not $old_dbd_warned) {
101 carp "Your DBD::Sybase is too old to support ".
102 "DBIx::Class::InflateColumn::DateTime, please upgrade!";
108 sub datetime_parser_type {
109 'DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::DateTime::Format'
112 package # hide from PAUSE
113 DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::DateTime::Format;
115 my $datetime_parse_format = '%Y-%m-%dT%H:%M:%S.%3NZ';
116 my $datetime_format_format = '%Y-%m-%d %H:%M:%S.%3N'; # %F %T
118 my ($datetime_parser, $datetime_formatter);
122 require DateTime::Format::Strptime;
123 $datetime_parser ||= DateTime::Format::Strptime->new(
124 pattern => $datetime_parse_format,
127 return $datetime_parser->parse_datetime(shift);
130 sub format_datetime {
132 require DateTime::Format::Strptime;
133 $datetime_formatter ||= DateTime::Format::Strptime->new(
134 pattern => $datetime_format_format,
137 return $datetime_formatter->format_datetime(shift);
144 DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server - Support for Microsoft
145 SQL Server via DBD::Sybase
149 This subclass supports MSSQL server connections via L<DBD::Sybase>.
153 This driver tries to determine whether your version of L<DBD::Sybase> and
154 supporting libraries (usually FreeTDS) support using placeholders, if not the
155 storage will be reblessed to
156 L<DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars>.
158 The MSSQL specific functionality is provided by
159 L<DBIx::Class::Storage::DBI::MSSQL>.
163 See L<DBIx::Class/CONTRIBUTORS>.
167 You may distribute this code under the same terms as Perl itself.