1 package DBIx::Class::Storage::DBI::Sybase;
6 use base qw/DBIx::Class::Storage::DBI/;
11 if (ref($self) eq 'DBIx::Class::Storage::DBI::Sybase') {
13 @{$self->dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2]
18 my $subclass = "DBIx::Class::Storage::DBI::Sybase::${dbtype}";
20 if (!$exception && $dbtype && $self->load_optional_class($subclass)) {
21 bless $self, $subclass;
23 } else { # probably real Sybase
24 if (not $self->dbh->{syb_dynamic_supported}) {
25 bless $self, 'DBIx::Class::Storage:DBI::Sybase::NoBindVars';
29 $self->dbh->syb_date_fmt('ISO_strict');
30 $self->dbh->do('set dateformat mdy');
35 sub _dbh_last_insert_id {
36 my ($self, $dbh, $source, $col) = @_;
38 if (not $self->dbh->{syb_dynamic_supported}) {
39 # @@identity works only if not using placeholders
40 # Should this query be cached?
41 return ($dbh->selectrow_array('select @@identity'))[0];
44 # sorry, there's no other way!
45 my $sth = $dbh->prepare_cached("select max($col) from ".$source->from);
46 return ($dbh->selectrow_array($sth))[0];
49 sub datetime_parser_type { "DBIx::Class::Storage::DBI::Sybase::DateTime" }
55 DBIx::Class::Storage::DBI::Sybase - Storage::DBI subclass for Sybase
59 This subclass supports L<DBD::Sybase> for real Sybase databases. If
60 you are using an MSSQL database via L<DBD::Sybase>, see
61 L<DBIx::Class::Storage::DBI::Sybase::MSSQL>.
65 If your version of Sybase does not support placeholders, then this storage
66 driver uses L<DBIx::Class::Storage::DBI::NoBindVars> as a base,
68 In which case, bind variables will be interpolated (properly quoted of course)
69 into the SQL query itself, without using bind placeholders.
71 More importantly this means that caching of prepared statements is explicitly
72 disabled, as the interpolation renders it useless.
74 If your version of Sybase B<DOES> support placeholders (check
75 C<<$dbh->{syb_dynamic_supported}>> then unfortunately there's no way to get the
76 C<last_insert_id> without doing a C<select max(col)>.
78 But your queries will be cached.
82 On connection C<syb_date_fmt> is set to C<ISO_strict>, e.g.:
83 C<2004-08-21T14:36:48.080Z> and C<dateformat> is set to C<mdy>, e.g.:
86 You will need the L<DateTime::Format::Strptime> module if you are going to use
87 L<DBIx::Class::InflateColumn::DateTime>.
91 Brandon L Black <blblack@gmail.com>
93 Justin Hunter <justin.d.hunter@gmail.com>
95 Rafael Kitover <rkitover@cpan.org>
99 You may distribute this code under the same terms as Perl itself.