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__;
19 if (not $self->_typeless_placeholders_supported) {
21 DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars;
23 'DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars';
28 sub _run_connection_actions {
31 # LongReadLen doesn't work with MSSQL through DBD::Sybase, and the default is
32 # huge on some versions of SQL server and can cause memory problems, so we
33 # fix it up here (see ::DBI::Sybase.pm)
36 $self->next::method(@_);
42 $self->_get_dbh->do('BEGIN TRAN');
48 or $self->throw_exception('cannot COMMIT on a disconnected handle');
55 or $self->throw_exception('cannot ROLLBACK on a disconnected handle');
59 sub _get_server_version {
62 my $product_version = $self->_get_dbh->selectrow_hashref('master.dbo.xp_msver ProductVersion');
64 if ((my $version = $product_version->{Character_Value}) =~ /^(\d+)\./) {
68 $self->throw_exception(
69 "MSSQL Version Retrieval Failed, Your ProductVersion's Character_Value is missing or malformed!"
74 =head2 connect_call_datetime_setup
78 on_connect_call => 'datetime_setup'
80 In L<connect_info|DBIx::Class::Storage::DBI/connect_info> to set:
82 $dbh->syb_date_fmt('ISO_strict'); # output fmt: 2004-08-21T14:36:48.080Z
84 On connection for use with L<DBIx::Class::InflateColumn::DateTime>
86 This works for both C<DATETIME> and C<SMALLDATETIME> columns, although
87 C<SMALLDATETIME> columns only have minute precision.
92 my $old_dbd_warned = 0;
94 sub connect_call_datetime_setup {
96 my $dbh = $self->_get_dbh;
98 if ($dbh->can('syb_date_fmt')) {
99 # amazingly, this works with FreeTDS
100 $dbh->syb_date_fmt('ISO_strict');
101 } elsif (not $old_dbd_warned) {
102 carp "Your DBD::Sybase is too old to support ".
103 "DBIx::Class::InflateColumn::DateTime, please upgrade!";
109 sub datetime_parser_type {
110 'DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::DateTime::Format'
113 package # hide from PAUSE
114 DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::DateTime::Format;
116 my $datetime_parse_format = '%Y-%m-%dT%H:%M:%S.%3NZ';
117 my $datetime_format_format = '%Y-%m-%d %H:%M:%S.%3N'; # %F %T
119 my ($datetime_parser, $datetime_formatter);
123 require DateTime::Format::Strptime;
124 $datetime_parser ||= DateTime::Format::Strptime->new(
125 pattern => $datetime_parse_format,
128 return $datetime_parser->parse_datetime(shift);
131 sub format_datetime {
133 require DateTime::Format::Strptime;
134 $datetime_formatter ||= DateTime::Format::Strptime->new(
135 pattern => $datetime_format_format,
138 return $datetime_formatter->format_datetime(shift);
145 DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server - Support for Microsoft
146 SQL Server via DBD::Sybase
150 This subclass supports MSSQL server connections via L<DBD::Sybase>.
154 This driver tries to determine whether your version of L<DBD::Sybase> and
155 supporting libraries (usually FreeTDS) support using placeholders, if not the
156 storage will be reblessed to
157 L<DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars>.
159 The MSSQL specific functionality is provided by
160 L<DBIx::Class::Storage::DBI::MSSQL>.
164 See L<DBIx::Class/CONTRIBUTORS>.
168 You may distribute this code under the same terms as Perl itself.