1 package DBIx::Class::Storage::DBI::Sybase;
6 use base qw/DBIx::Class::Storage::DBI/;
8 use Carp::Clan qw/^DBIx::Class/;
13 if (ref($self) eq 'DBIx::Class::Storage::DBI::Sybase') {
15 @{$self->dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2]
20 my $subclass = "DBIx::Class::Storage::DBI::Sybase::${dbtype}";
22 if (!$exception && $dbtype && $self->load_optional_class($subclass)) {
23 bless $self, $subclass;
25 } elsif (not $self->dbh->{syb_dynamic_supported}) {
26 bless $self, 'DBIx::Class::Storage:DBI::Sybase::NoBindVars';
33 my $old_dbd_warned = 0;
37 $self->next::method(@_);
38 my $dbh = $self->_dbh;
40 if ($dbh->can('syb_date_fmt')) {
41 $dbh->syb_date_fmt('ISO_strict');
42 } elsif (not $old_dbd_warned) {
43 carp "Your DBD::Sybase is too old to support ".
44 "DBIx::Class::InflateColumn::DateTime, please upgrade!";
48 $dbh->do('set dateformat mdy');
54 sub _dbh_last_insert_id {
55 my ($self, $dbh, $source, $col) = @_;
57 # sorry, there's no other way!
58 my $sth = $dbh->prepare_cached("select max($col) from ".$source->from);
59 return ($dbh->selectrow_array($sth))[0];
63 my ($self, $source, $attrs) = @_;
65 if (exists $attrs->{rows}) {
66 my $new_attrs = $self->_trim_attributes_for_count($source, $attrs);
68 $new_attrs->{select} = '1';
69 $new_attrs->{as} = ['dummy'];
71 # speed things up at least *a little*
72 $new_attrs->{result_class} = 'DBIx::Class::ResultClass::HashRefInflator';
74 my $offset = $attrs->{offset} || 0;
75 my $total = $attrs->{rows} + $offset;
77 $self->dbh->do("set rowcount $total");
79 my $tmp_rs = $source->resultset_class->new($source, $new_attrs);
82 $count++ while $tmp_rs->cursor->next;
84 $self->dbh->do("set rowcount 0");
89 return $self->next::method(@_);
92 sub datetime_parser_type { "DBIx::Class::Storage::DBI::Sybase::DateTime" }
98 DBIx::Class::Storage::DBI::Sybase - Storage::DBI subclass for Sybase
102 This subclass supports L<DBD::Sybase> for real Sybase databases. If you are
103 using an MSSQL database via L<DBD::Sybase>, your storage will be reblessed to
104 L<DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server>.
108 If your version of Sybase does not support placeholders, then your storage
109 will be reblessed to L<DBIx::Class::Storage::DBI::Sybase::NoBindVars>. You can
110 also enable that driver explicitly, see the documentation for more details.
112 With this driver there is unfortunately no way to get the C<last_insert_id>
113 without doing a C<select max(col)>.
115 But your queries will be cached.
119 On connection C<syb_date_fmt> is set to C<ISO_strict>, e.g.:
120 C<2004-08-21T14:36:48.080Z> and C<dateformat> is set to C<mdy>, e.g.:
121 C<08/13/1979 18:08:55.080>.
123 This works for both C<DATETIME> and C<SMALLDATETIME> columns, although
124 C<SMALLDATETIME> columns only have minute precision.
126 You will need the L<DateTime::Format::Strptime> module if you are going to use
127 L<DBIx::Class::InflateColumn::DateTime>.
131 See L<DBIx::Class/CONTRIBUTORS>.
135 You may distribute this code under the same terms as Perl itself.