X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FPK%2FAuto%2FOracle.pm;h=391b72a691edbf21d10ae10f6113699eacdbcbfe;hb=92705f7f05161f7dba36d9b09dc6e893af7b2773;hp=e12b16c5242199e261a609453463913a786ed541;hpb=aa5624077a0da8763f3482b5912c45e97b4214f8;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/PK/Auto/Oracle.pm b/lib/DBIx/Class/PK/Auto/Oracle.pm index e12b16c..391b72a 100644 --- a/lib/DBIx/Class/PK/Auto/Oracle.pm +++ b/lib/DBIx/Class/PK/Auto/Oracle.pm @@ -1,77 +1,32 @@ -package DBIx::Class::PK::Auto::Oracle; +package # hide package from pause + DBIx::Class::PK::Auto::Oracle; use strict; use warnings; -use Carp qw/croak/; - use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/PK::Auto/); -sub last_insert_id { - my $self = shift; - $self->get_autoinc_seq unless $self->{_autoinc_seq}; - my $sql = "SELECT " . $self->{_autoinc_seq} . ".currval FROM DUAL"; - my ($id) = $self->result_source->storage->dbh->selectrow_array($sql); - return $id; -} - -sub get_autoinc_seq { - my $self = shift; - - # return the user-defined sequence if known - if ($self->sequence) { - return $self->{_autoinc_seq} = $self->sequence; - } - - # look up the correct sequence automatically - my $dbh = $self->result_source->storage->dbh; - my $sql = qq{ - SELECT trigger_body FROM ALL_TRIGGERS t - WHERE t.table_name = ? - AND t.triggering_event = 'INSERT' - AND t.status = 'ENABLED' - }; - # trigger_body is a LONG - $dbh->{LongReadLen} = 64 * 1024 if ($dbh->{LongReadLen} < 64 * 1024); - my $sth = $dbh->prepare($sql); - $sth->execute( uc($self->result_source->name) ); - while (my ($insert_trigger) = $sth->fetchrow_array) { - if ($insert_trigger =~ m!(\w+)\.nextval!i ) { - $self->{_autoinc_seq} = uc($1); - } - } - unless ($self->{_autoinc_seq}) { - croak "Unable to find a sequence INSERT trigger on table '" . $self->_table_name . "'."; - } -} - 1; -=head1 NAME +__END__ -DBIx::Class::PK::Auto::Oracle - Automatic Primary Key class for Oracle - -=head1 SYNOPSIS +=head1 NAME - # In your table classes - __PACKAGE__->load_components(qw/PK::Auto::Oracle Core/); - __PACKAGE__->set_primary_key('id'); +DBIx::Class::PK::Auto::Oracle - (DEPRECATED) Automatic primary key class for Oracle -=head1 DESCRIPTION - -This class implements autoincrements for Oracle. - -=head1 AUTHORS - -Andy Grundman +=head1 SYNOPSIS -Scott Connelly +Just load PK::Auto instead; auto-inc is now handled by Storage. -=head1 LICENSE +=head1 FURTHER QUESTIONS? -You may distribute this code under the same terms as Perl itself. +Check the list of L. -=cut +=head1 COPYRIGHT AND LICENSE +This module is free software L +by the L. You can +redistribute it and/or modify it under the same terms as the +L.