1 package DBIx::Class::PK::Auto::Oracle;
6 use base qw/DBIx::Class/;
8 __PACKAGE__->load_components(qw/PK::Auto/);
12 $self->get_autoinc_seq unless $self->{_autoinc_seq};
13 my $sql = "SELECT " . $self->{_autoinc_seq} . ".nextval FROM DUAL";
14 my ($id) = $self->storage->dbh->selectrow_array($sql);
21 # return the user-defined sequence if known
22 if ($self->sequence) {
23 return $self->{_autoinc_seq} = $self->sequence;
26 # look up the correct sequence automatically
27 my $dbh = $self->storage->dbh;
29 SELECT trigger_body FROM ALL_TRIGGERS t
30 WHERE t.table_name = ?
31 AND t.triggering_event = 'INSERT'
32 AND t.status = 'ENABLED'
34 # trigger_body is a LONG
35 $dbh->{LongReadLen} = 64 * 1024 if ($dbh->{LongReadLen} < 64 * 1024);
36 my $sth = $dbh->prepare($sql);
37 $sth->execute( uc($self->_table_name) );
38 while (my ($insert_trigger) = $sth->fetchrow_array) {
39 if ($insert_trigger =~ m!(\w+)\.nextval!i ) {
40 $self->{_autoinc_seq} = uc($1);
43 unless ($self->{_autoinc_seq}) {
44 die "Unable to find a sequence INSERT trigger on table '" . $self->_table_name . "'.";
52 DBIx::Class::PK::Auto::Oracle - Automatic Primary Key class for Oracle
58 This class implements autoincrements for Oracle.
62 Andy Grundman <andy@hybridized.org>
64 Scott Connelly <scottsweep@yahoo.com>
68 You may distribute this code under the same terms as Perl itself.