1 package DBIx::Class::Storage::DBI::Informix;
5 use base qw/DBIx::Class::Storage::DBI/;
9 use Context::Preserve 'preserve_context';
12 __PACKAGE__->sql_limit_dialect ('SkipFirst');
13 __PACKAGE__->sql_quote_char ('"');
15 __PACKAGE__->mk_group_accessors('simple' => '__last_insert_id');
19 DBIx::Class::Storage::DBI::Informix - Base Storage Class for Informix Support
23 This class implements storage-specific support for the Informix RDBMS
32 my ($rv, $sth, @rest) = $self->next::method(@_);
33 if ($op eq 'insert') {
34 $self->__last_insert_id($sth->{ix_sqlerrd}[1]);
36 return (wantarray ? ($rv, $sth, @rest) : $rv);
40 shift->__last_insert_id;
44 my ($self, $name) = @_;
46 $self->_get_dbh->do("SAVEPOINT $name");
49 # can't release savepoints
50 sub _svp_release { 1 }
53 my ($self, $name) = @_;
55 $self->_get_dbh->do("ROLLBACK TO SAVEPOINT $name")
58 sub with_deferred_fk_checks {
59 my ($self, $sub) = @_;
61 my $txn_scope_guard = $self->txn_scope_guard;
63 $self->_do_query('SET CONSTRAINTS ALL DEFERRED');
65 my $sg = Scope::Guard->new(sub {
66 $self->_do_query('SET CONSTRAINTS ALL IMMEDIATE');
69 return preserve_context { $sub->() } after => sub { $txn_scope_guard->commit };
72 =head2 connect_call_datetime_setup
76 on_connect_call => 'datetime_setup'
78 In L<connect_info|DBIx::Class::Storage::DBI/connect_info> to set the C<DATE> and
81 Sets the following environment variables:
84 GL_DATETIME="%Y-%m-%d %H:%M:%S%F5"
86 The C<DBDATE> and C<DBCENTURY> environment variables are cleared.
88 B<NOTE:> setting the C<GL_DATE> environment variable seems to have no effect
89 after the process has started, so the default format is used. The C<GL_DATETIME>
90 setting does take effect however.
92 The C<DATETIME> data type supports up to 5 digits after the decimal point for
93 second precision, depending on how you have declared your column. The full
94 possible precision is used.
96 The column declaration for a C<DATETIME> with maximum precision is:
98 column_name DATETIME YEAR TO FRACTION(5)
100 The C<DATE> data type stores the date portion only, and it B<MUST> be declared
105 in your Result class.
107 You will need the L<DateTime::Format::Strptime> module for inflation to work.
111 sub connect_call_datetime_setup {
114 delete @ENV{qw/DBDATE DBCENTURY/};
116 $ENV{GL_DATE} = "%m/%d/%Y";
117 $ENV{GL_DATETIME} = "%Y-%m-%d %H:%M:%S%F5";
120 sub datetime_parser_type {
121 'DBIx::Class::Storage::DBI::Informix::DateTime::Format'
124 package # hide from PAUSE
125 DBIx::Class::Storage::DBI::Informix::DateTime::Format;
127 my $timestamp_format = '%Y-%m-%d %H:%M:%S.%5N'; # %F %T
128 my $date_format = '%m/%d/%Y';
130 my ($timestamp_parser, $date_parser);
134 require DateTime::Format::Strptime;
135 $timestamp_parser ||= DateTime::Format::Strptime->new(
136 pattern => $timestamp_format,
139 return $timestamp_parser->parse_datetime(shift);
142 sub format_datetime {
144 require DateTime::Format::Strptime;
145 $timestamp_parser ||= DateTime::Format::Strptime->new(
146 pattern => $timestamp_format,
149 return $timestamp_parser->format_datetime(shift);
154 require DateTime::Format::Strptime;
155 $date_parser ||= DateTime::Format::Strptime->new(
156 pattern => $date_format,
159 return $date_parser->parse_datetime(shift);
164 require DateTime::Format::Strptime;
165 $date_parser ||= DateTime::Format::Strptime->new(
166 pattern => $date_format,
169 return $date_parser->format_datetime(shift);
176 See L<DBIx::Class/AUTHOR> and L<DBIx::Class/CONTRIBUTORS>.
180 You may distribute this code under the same terms as Perl itself.