1 package DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server;
7 DBIx::Class::Storage::DBI::Sybase
8 DBIx::Class::Storage::DBI::MSSQL
12 use DBIx::Class::Carp;
16 DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server - Support for Microsoft
17 SQL Server via DBD::Sybase
21 This subclass supports MSSQL server connections via L<DBD::Sybase>.
25 This driver tries to determine whether your version of L<DBD::Sybase> and
26 supporting libraries (usually FreeTDS) support using placeholders, if not the
27 storage will be reblessed to
28 L<DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars>.
30 The MSSQL specific functionality is provided by
31 L<DBIx::Class::Storage::DBI::MSSQL>.
37 __PACKAGE__->datetime_parser_type(
38 'DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::DateTime::Format'
43 my $dbh = $self->_get_dbh;
45 return if ref $self ne __PACKAGE__;
46 if (not $self->_use_typeless_placeholders) {
47 carp_once <<'EOF' unless $ENV{DBIC_MSSQL_FREETDS_LOWVER_NOWARN};
48 Placeholders do not seem to be supported in your configuration of
51 This means you are taking a large performance hit, as caching of prepared
52 statements is disabled.
54 Make sure to configure your server with "tds version" of 8.0 or 7.0 in
55 /etc/freetds/freetds.conf .
57 To turn off this warning, set the DBIC_MSSQL_FREETDS_LOWVER_NOWARN environment
61 DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars;
63 'DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars';
68 # invoked only if DBD::Sybase is compiled against FreeTDS
69 sub _set_autocommit_stmt {
72 return 'SET IMPLICIT_TRANSACTIONS ' . ($on ? 'OFF' : 'ON');
75 sub _get_server_version {
78 my $product_version = $self->_get_dbh->selectrow_hashref('master.dbo.xp_msver ProductVersion');
80 if ((my $version = $product_version->{Character_Value}) =~ /^(\d+)\./) {
84 $self->throw_exception(
85 "MSSQL Version Retrieval Failed, Your ProductVersion's Character_Value is missing or malformed!"
90 =head2 connect_call_datetime_setup
94 on_connect_call => 'datetime_setup'
96 In L<connect_info|DBIx::Class::Storage::DBI/connect_info> to set:
98 $dbh->syb_date_fmt('ISO_strict'); # output fmt: 2004-08-21T14:36:48.080Z
100 On connection for use with L<DBIx::Class::InflateColumn::DateTime>
102 This works for both C<DATETIME> and C<SMALLDATETIME> columns, although
103 C<SMALLDATETIME> columns only have minute precision.
107 sub connect_call_datetime_setup {
109 my $dbh = $self->_get_dbh;
111 if ($dbh->can('syb_date_fmt')) {
112 # amazingly, this works with FreeTDS
113 $dbh->syb_date_fmt('ISO_strict');
117 'Your DBD::Sybase is too old to support '
118 . 'DBIx::Class::InflateColumn::DateTime, please upgrade!';
123 package # hide from PAUSE
124 DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::DateTime::Format;
126 my $datetime_parse_format = '%Y-%m-%dT%H:%M:%S.%3NZ';
127 my $datetime_format_format = '%Y-%m-%d %H:%M:%S.%3N'; # %F %T
129 my ($datetime_parser, $datetime_formatter);
133 require DateTime::Format::Strptime;
134 $datetime_parser ||= DateTime::Format::Strptime->new(
135 pattern => $datetime_parse_format,
138 return $datetime_parser->parse_datetime(shift);
141 sub format_datetime {
143 require DateTime::Format::Strptime;
144 $datetime_formatter ||= DateTime::Format::Strptime->new(
145 pattern => $datetime_format_format,
148 return $datetime_formatter->format_datetime(shift);
155 See L<DBIx::Class/CONTRIBUTORS>.
159 You may distribute this code under the same terms as Perl itself.