Class::DBI::Plugin::DateFormat::Oracle - Extension to Class::DBI for Oracle date fields.


Class-DBI-Plugin-DateFormat-Oracle documentation Contained in the Class-DBI-Plugin-DateFormat-Oracle distribution.

Index


Code Index:

NAME

Top

Class::DBI::Plugin::DateFormat::Oracle - Extension to Class::DBI for Oracle date fields.

VERSION

Top

This documentation refers to Class::DBI::Plugin::DateFormat::Oracle version 0.01

SYNOPSIS

Top

  package YourBase::CDBI;
  use base 'Class::DBI';
  __PACKAGE__->connection('dbi:Oracle:sid', user, pwd);
  __PACKAGE__->set_nls_date_format('YY/MM/DD HH24:MI:SS');
  $format = __PACKAGE__->get_nls_date_format;

DESCRIPTION

Top

This module is Extension to Class::DBI for Oracle date fields.

METHOD

Top

set_nls_date_format

  __PACKAGE__->set_nls_date_format('YY/MM/DD HH24:MI:SS');

This method sets Oracle date field's format. This method execute "ALTER SESSION".

get_nls_date_format

  $format = __PACKAGE__->get_nls_date_format;

This method gets Oracle date field's format.

DEPENDENCIES

Top

Class::DBI

Carp

SEE ALSO

Top

Class::DBI

Carp

Class::DBI's Cookbook

http://cdbi.dcmanaged.com/wiki/Working_With_Oracle_Date_Fields

Refer to the Oracle documentation for valid date formats.

BUGS AND LIMITATIONS

Top

There are no known bugs in this module. Please report problems to Atsushi Kobayashi (<nekokak@cpan.org>) Patches are welcome.

AUTHOR

Top

Atsushi Kobayashi, <nekokak@cpan.org>

COPYRIGHT AND LICENSE

Top


Class-DBI-Plugin-DateFormat-Oracle documentation Contained in the Class-DBI-Plugin-DateFormat-Oracle distribution.

package Class::DBI::Plugin::DateFormat::Oracle;

use strict;
use warnings;
use Carp;
use vars '$VERSION';

$VERSION = '0.01';

sub import {
    my $class = shift;
    my $pkg   = caller(0);

    no strict 'refs';
    *{"$pkg\::set_nls_date_format"} = sub {
        my $self   = shift;
        my $format = shift;

        eval {
            $pkg->db_Main->do(qq[ALTER SESSION SET NLS_DATE_FORMAT = '$format']);
        };
        $self->_croak("ALTER SESSION ERROR ".$@ ) if $@;
    };

    *{"$pkg\::get_nls_date_format"} = sub {
        my $self = shift;
        my $date_format;

        $self->set_sql(nls_date_format => q[SELECT VALUE FROM v$nls_parameters WHERE PARAMETER = 'NLS_DATE_FORMAT']);

        eval {
            $date_format = $self->search_nls_date_format->first->{value};
        };

        $self->_croak("SELECT NLS_DATE_FORMAT ERROR ".$@ ) if $@;
        return $date_format;
    }
}

1;
__END__