1 package DBIx::Class::Storage::DBI::InterBase;
5 use base qw/DBIx::Class::Storage::DBI::Firebird::Common/;
12 DBIx::Class::Storage::DBI::InterBase - Driver for the Firebird RDBMS via
17 This driver is a subclass of L<DBIx::Class::Storage::DBI::Firebird::Common> for
18 use with L<DBD::InterBase>, see that driver for general details.
20 You need to use either the
21 L<disable_sth_caching|DBIx::Class::Storage::DBI/disable_sth_caching> option or
22 L</connect_call_use_softcommit> (see L</CAVEATS>) for your code to function
23 correctly with this driver. Otherwise you will likely get bizarre error messages
24 such as C<no statement executing>. The alternative is to use the
25 L<ODBC|DBIx::Class::Storage::DBI::ODBC::Firebird> driver, which is more suitable
26 for long running processes such as under L<Catalyst>.
28 To turn on L<DBIx::Class::InflateColumn::DateTime> support, see
29 L</connect_call_datetime_setup>.
33 __PACKAGE__->datetime_parser_type(
34 'DBIx::Class::Storage::DBI::InterBase::DateTime::Format'
40 my $dbh = $self->_dbh or return 0;
42 local $dbh->{RaiseError} = 1;
43 local $dbh->{PrintError} = 0;
46 $dbh->do('select 1 from rdb$database');
53 # We want dialect 3 for new features and quoting to work, DBD::InterBase uses
54 # dialect 1 (interbase compat) by default.
57 $self->_set_sql_dialect(3);
60 sub _set_sql_dialect {
64 my $dsn = $self->_dbi_connect_info->[0];
66 return if ref($dsn) eq 'CODE';
68 if ($dsn !~ /ib_dialect=/) {
69 $self->_dbi_connect_info->[0] = "$dsn;ib_dialect=$val";
70 my $connected = defined $self->_dbh;
72 $self->ensure_connected if $connected;
76 =head2 connect_call_use_softcommit
80 on_connect_call => 'use_softcommit'
82 In L<connect_info|DBIx::Class::Storage::DBI/connect_info> to set the
83 L<DBD::InterBase> C<ib_softcommit> option.
85 You need either this option or C<< disable_sth_caching => 1 >> for
86 L<DBIx::Class> code to function correctly (otherwise you may get C<no statement
87 executing> errors.) Or use the L<ODBC|DBIx::Class::Storage::DBI::ODBC::Firebird>
90 The downside of using this option is that your process will B<NOT> see UPDATEs,
91 INSERTs and DELETEs from other processes for already open statements.
95 sub connect_call_use_softcommit {
98 $self->_dbh->{ib_softcommit} = 1;
101 =head2 connect_call_datetime_setup
105 on_connect_call => 'datetime_setup'
107 In L<connect_info|DBIx::Class::Storage::DBI/connect_info> to set the date and
108 timestamp formats using:
110 $dbh->{ib_time_all} = 'ISO';
112 See L<DBD::InterBase> for more details.
114 The C<TIMESTAMP> data type supports up to 4 digits after the decimal point for
115 second precision. The full precision is used.
117 The C<DATE> data type stores the date portion only, and it B<MUST> be declared
122 in your Result class.
124 Timestamp columns can be declared with either C<datetime> or C<timestamp>.
126 You will need the L<DateTime::Format::Strptime> module for inflation to work.
128 For L<DBIx::Class::Storage::DBI::ODBC::Firebird>, this is a noop.
132 sub connect_call_datetime_setup {
135 $self->_get_dbh->{ib_time_all} = 'ISO';
139 package # hide from PAUSE
140 DBIx::Class::Storage::DBI::InterBase::DateTime::Format;
142 my $timestamp_format = '%Y-%m-%d %H:%M:%S.%4N'; # %F %T
143 my $date_format = '%Y-%m-%d';
145 my ($timestamp_parser, $date_parser);
149 require DateTime::Format::Strptime;
150 $timestamp_parser ||= DateTime::Format::Strptime->new(
151 pattern => $timestamp_format,
154 return $timestamp_parser->parse_datetime(shift);
157 sub format_datetime {
159 require DateTime::Format::Strptime;
160 $timestamp_parser ||= DateTime::Format::Strptime->new(
161 pattern => $timestamp_format,
164 return $timestamp_parser->format_datetime(shift);
169 require DateTime::Format::Strptime;
170 $date_parser ||= DateTime::Format::Strptime->new(
171 pattern => $date_format,
174 return $date_parser->parse_datetime(shift);
179 require DateTime::Format::Strptime;
180 $date_parser ||= DateTime::Format::Strptime->new(
181 pattern => $date_format,
184 return $date_parser->format_datetime(shift);
195 with L</connect_call_use_softcommit>, you will not be able to see changes made
196 to data in other processes. If this is an issue, use
197 L<disable_sth_caching|DBIx::Class::Storage::DBI/disable_sth_caching> as a
198 workaround for the C<no statement executing> errors, this of course adversely
201 Alternately, use the L<ODBC|DBIx::Class::Storage::DBI::ODBC::Firebird> driver.
207 See L<DBIx::Class/AUTHOR> and L<DBIx::Class/CONTRIBUTORS>.
211 You may distribute this code under the same terms as Perl itself.