1 package DBIx::Class::Storage::DBI::Informix;
5 use base qw/DBIx::Class::Storage::DBI/;
9 __PACKAGE__->mk_group_accessors('simple' => '__last_insert_id');
13 DBIx::Class::Storage::DBI::Informix - Base Storage Class for Informix Support
17 This class implements storage-specific support for the Informix RDBMS
26 my ($rv, $sth, @rest) = $self->next::method(@_);
27 if ($op eq 'insert') {
28 $self->__last_insert_id($sth->{ix_sqlerrd}[1]);
30 return (wantarray ? ($rv, $sth, @rest) : $rv);
34 shift->__last_insert_id;
38 my ( $self, $opts ) = @_;
41 $self->{_sql_maker_opts} = { %$opts };
44 return { limit_dialect => 'SkipFirst', %{$self->{_sql_maker_opts}||{}} };
48 my ($self, $name) = @_;
50 $self->_get_dbh->do("SAVEPOINT $name");
53 # can't release savepoints
54 sub _svp_release { 1 }
57 my ($self, $name) = @_;
59 $self->_get_dbh->do("ROLLBACK TO SAVEPOINT $name")
62 =head2 connect_call_datetime_setup
66 on_connect_call => 'datetime_setup'
68 In L<connect_info|DBIx::Class::Storage::DBI/connect_info> to set the C<DATE> and
71 Sets the following environment variables:
74 GL_DATETIME="%Y-%m-%d %H:%M:%S%F5"
76 The C<DBDATE> and C<DBCENTURY> environment variables are cleared.
78 B<NOTE:> setting the C<GL_DATE> environment variable seems to have no effect
79 after the process has started, so the default format is used. The C<GL_DATETIME>
80 setting does take effect however.
82 The C<DATETIME> data type supports up to 5 digits after the decimal point for
83 second precision, depending on how you have declared your column. The full
84 possible precision is used.
86 The column declaration for a C<DATETIME> with maximum precision is:
88 column_name DATETIME YEAR TO FRACTION(5)
90 The C<DATE> data type stores the date portion only, and it B<MUST> be declared
97 You will need the L<DateTime::Format::Strptime> module for inflation to work.
101 sub connect_call_datetime_setup {
104 delete @ENV{qw/DBDATE DBCENTURY/};
106 $ENV{GL_DATE} = "%m/%d/%Y";
107 $ENV{GL_DATETIME} = "%Y-%m-%d %H:%M:%S%F5";
110 sub datetime_parser_type {
111 'DBIx::Class::Storage::DBI::Informix::DateTime::Format'
114 package # hide from PAUSE
115 DBIx::Class::Storage::DBI::Informix::DateTime::Format;
117 my $timestamp_format = '%Y-%m-%d %H:%M:%S.%5N'; # %F %T
118 my $date_format = '%m/%d/%Y';
120 my ($timestamp_parser, $date_parser);
124 require DateTime::Format::Strptime;
125 $timestamp_parser ||= DateTime::Format::Strptime->new(
126 pattern => $timestamp_format,
129 return $timestamp_parser->parse_datetime(shift);
132 sub format_datetime {
134 require DateTime::Format::Strptime;
135 $timestamp_parser ||= DateTime::Format::Strptime->new(
136 pattern => $timestamp_format,
139 return $timestamp_parser->format_datetime(shift);
144 require DateTime::Format::Strptime;
145 $date_parser ||= DateTime::Format::Strptime->new(
146 pattern => $date_format,
149 return $date_parser->parse_datetime(shift);
154 require DateTime::Format::Strptime;
155 $date_parser ||= DateTime::Format::Strptime->new(
156 pattern => $date_format,
159 return $date_parser->format_datetime(shift);
166 See L<DBIx::Class/AUTHOR> and L<DBIx::Class/CONTRIBUTORS>.
170 You may distribute this code under the same terms as Perl itself.