1 package DBIx::Class::Storage::DBI::Informix;
5 use base qw/DBIx::Class::Storage::DBI/;
9 use Scalar::Util 'weaken';
10 use Context::Preserve 'preserve_context';
13 __PACKAGE__->sql_limit_dialect ('SkipFirst');
14 __PACKAGE__->sql_quote_char ('"');
15 __PACKAGE__->datetime_parser_type (
16 'DBIx::Class::Storage::DBI::Informix::DateTime::Format'
20 __PACKAGE__->mk_group_accessors('simple' => '__last_insert_id');
24 DBIx::Class::Storage::DBI::Informix - Base Storage Class for Informix Support
28 This class implements storage-specific support for the Informix RDBMS
36 my ($rv, $sth, @rest) = $self->next::method(@_);
38 $self->__last_insert_id($sth->{ix_sqlerrd}[1])
39 if $self->_perform_autoinc_retrieval;
41 return (wantarray ? ($rv, $sth, @rest) : $rv);
45 shift->__last_insert_id;
49 my ($self, $name) = @_;
51 $self->_dbh->do("SAVEPOINT $name");
54 # can't release savepoints
55 sub _exec_svp_release { 1 }
57 sub _exec_svp_rollback {
58 my ($self, $name) = @_;
60 $self->_dbh->do("ROLLBACK TO SAVEPOINT $name")
63 sub with_deferred_fk_checks {
64 my ($self, $sub) = @_;
66 my $txn_scope_guard = $self->txn_scope_guard;
68 $self->_do_query('SET CONSTRAINTS ALL DEFERRED');
71 return preserve_context {
72 my $sg = Scope::Guard->new(sub {
73 $self->_do_query('SET CONSTRAINTS ALL IMMEDIATE');
76 } after => sub { $txn_scope_guard->commit };
79 =head2 connect_call_datetime_setup
83 on_connect_call => 'datetime_setup'
85 In L<connect_info|DBIx::Class::Storage::DBI/connect_info> to set the C<DATE> and
88 Sets the following environment variables:
91 GL_DATETIME="%Y-%m-%d %H:%M:%S%F5"
93 The C<DBDATE> and C<DBCENTURY> environment variables are cleared.
95 B<NOTE:> setting the C<GL_DATE> environment variable seems to have no effect
96 after the process has started, so the default format is used. The C<GL_DATETIME>
97 setting does take effect however.
99 The C<DATETIME> data type supports up to 5 digits after the decimal point for
100 second precision, depending on how you have declared your column. The full
101 possible precision is used.
103 The column declaration for a C<DATETIME> with maximum precision is:
105 column_name DATETIME YEAR TO FRACTION(5)
107 The C<DATE> data type stores the date portion only, and it B<MUST> be declared
112 in your Result class.
114 You will need the L<DateTime::Format::Strptime> module for inflation to work.
118 sub connect_call_datetime_setup {
121 delete @ENV{qw/DBDATE DBCENTURY/};
123 $ENV{GL_DATE} = "%m/%d/%Y";
124 $ENV{GL_DATETIME} = "%Y-%m-%d %H:%M:%S%F5";
127 package # hide from PAUSE
128 DBIx::Class::Storage::DBI::Informix::DateTime::Format;
130 my $timestamp_format = '%Y-%m-%d %H:%M:%S.%5N'; # %F %T
131 my $date_format = '%m/%d/%Y';
133 my ($timestamp_parser, $date_parser);
137 require DateTime::Format::Strptime;
138 $timestamp_parser ||= DateTime::Format::Strptime->new(
139 pattern => $timestamp_format,
142 return $timestamp_parser->parse_datetime(shift);
145 sub format_datetime {
147 require DateTime::Format::Strptime;
148 $timestamp_parser ||= DateTime::Format::Strptime->new(
149 pattern => $timestamp_format,
152 return $timestamp_parser->format_datetime(shift);
157 require DateTime::Format::Strptime;
158 $date_parser ||= DateTime::Format::Strptime->new(
159 pattern => $date_format,
162 return $date_parser->parse_datetime(shift);
167 require DateTime::Format::Strptime;
168 $date_parser ||= DateTime::Format::Strptime->new(
169 pattern => $date_format,
172 return $date_parser->format_datetime(shift);
175 =head1 FURTHER QUESTIONS?
177 Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
179 =head1 COPYRIGHT AND LICENSE
181 This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
182 by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
183 redistribute it and/or modify it under the same terms as the
184 L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.