1 package DBIx::Class::Schema::Loader::DBI::Oracle;
5 use base 'DBIx::Class::Schema::Loader::DBI';
6 use Carp::Clan qw/^DBIx::Class/;
9 our $VERSION = '0.04999_13';
13 DBIx::Class::Schema::Loader::DBI::Oracle - DBIx::Class::Schema::Loader::DBI
14 Oracle Implementation.
19 use base qw/DBIx::Class::Schema::Loader/;
21 __PACKAGE__->loader_options( debug => 1 );
27 See L<DBIx::Class::Schema::Loader::Base>.
29 This module is considered experimental and not well tested yet.
36 $self->next::method(@_);
38 my $dbh = $self->schema->storage->dbh;
40 my ($current_schema) = $dbh->selectrow_array('SELECT USER FROM DUAL', {});
42 $self->{db_schema} ||= $current_schema;
44 if (lc($self->db_schema) ne lc($current_schema)) {
45 $dbh->do('ALTER SESSION SET current_schema=' . $self->db_schema);
51 my ($self, $table) = @_;
53 my $dbh = $self->schema->storage->dbh;
55 my $sth = $dbh->prepare($self->schema->storage->sql_maker->select($table, undef, \'1 = 0'));
57 return \@{$sth->{NAME_lc}};
63 my $dbh = $self->schema->storage->dbh;
66 for my $table ( $dbh->tables(undef, $self->db_schema, '%', 'TABLE,VIEW') ) { #catalog, schema, table, type
67 my $quoter = $dbh->get_info(29);
68 $table =~ s/$quoter//g;
70 # remove "user." (schema) prefixes
73 next if $table eq 'PLAN_TABLE';
76 if $table =~ /\A(\w+)\z/;
81 sub _table_uniq_info {
82 my ($self, $table) = @_;
84 my $dbh = $self->schema->storage->dbh;
86 my $sth = $dbh->prepare_cached(
88 SELECT constraint_name, acc.column_name
89 FROM all_constraints JOIN all_cons_columns acc USING (constraint_name)
90 WHERE acc.table_name=? and acc.owner = ? AND constraint_type='U'
95 $sth->execute(uc $table,$self->{db_schema} );
97 while(my $constr = $sth->fetchrow_arrayref) {
98 my $constr_name = lc $constr->[0];
99 my $constr_def = lc $constr->[1];
100 $constr_name =~ s/\Q$self->{_quoter}\E//;
101 $constr_def =~ s/\Q$self->{_quoter}\E//;
102 push @{$constr_names{$constr_name}}, $constr_def;
105 my @uniqs = map { [ $_ => $constr_names{$_} ] } keys %constr_names;
110 my ($self, $table) = @_;
111 return $self->next::method(uc $table);
115 my ($self, $table) = @_;
117 my $rels = $self->next::method(uc $table);
119 foreach my $rel (@$rels) {
120 $rel->{remote_table} = lc $rel->{remote_table};
126 sub _columns_info_for {
127 my ($self, $table) = @_;
128 return $self->next::method(uc $table);
131 sub _extra_column_info {
132 my ($self, $info) = @_;
135 my ($table, $column) = @$info{qw/TABLE_NAME COLUMN_NAME/};
137 my $dbh = $self->schema->storage->dbh;
138 my $sth = $dbh->prepare_cached(
141 FROM all_triggers ut JOIN all_trigger_cols atc USING (trigger_name)
142 WHERE atc.table_name = ? AND atc.column_name = ?
143 AND column_usage LIKE '%NEW%' AND column_usage LIKE '%OUT%'
144 AND trigger_type = 'BEFORE EACH ROW' AND triggering_event LIKE '%INSERT%'
148 $sth->execute($table, $column);
149 if ($sth->fetchrow_array) {
150 $extra_info{is_auto_increment} = 1;
158 L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
159 L<DBIx::Class::Schema::Loader::DBI>
163 See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
167 This library is free software; you can redistribute it and/or modify it under
168 the same terms as Perl itself.