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_09';
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;
39 $self->{db_schema} ||= $dbh->selectrow_array('SELECT USER FROM DUAL', {});
44 my ($self, $table) = @_;
46 my $dbh = $self->schema->storage->dbh;
48 my $sth = $dbh->prepare($self->schema->storage->sql_maker->select($table, undef, \'1 = 0'));
50 return \@{$sth->{NAME_lc}};
56 my $dbh = $self->schema->storage->dbh;
59 for my $table ( $dbh->tables(undef, $self->db_schema, '%', 'TABLE,VIEW') ) { #catalog, schema, table, type
60 my $quoter = $dbh->get_info(29);
61 $table =~ s/$quoter//g;
63 # remove "user." (schema) prefixes
66 next if $table eq 'PLAN_TABLE';
69 if $table =~ /\A(\w+)\z/;
74 sub _table_uniq_info {
75 my ($self, $table) = @_;
77 my $dbh = $self->schema->storage->dbh;
79 my $sth = $dbh->prepare_cached(
81 SELECT constraint_name, acc.column_name
82 FROM all_constraints JOIN all_cons_columns acc USING (constraint_name)
83 WHERE acc.table_name=? and acc.owner = ? AND constraint_type='U'
88 $sth->execute(uc $table,$self->{db_schema} );
90 while(my $constr = $sth->fetchrow_arrayref) {
91 my $constr_name = lc $constr->[0];
92 my $constr_def = lc $constr->[1];
93 $constr_name =~ s/\Q$self->{_quoter}\E//;
94 $constr_def =~ s/\Q$self->{_quoter}\E//;
95 push @{$constr_names{$constr_name}}, $constr_def;
98 my @uniqs = map { [ $_ => $constr_names{$_} ] } keys %constr_names;
103 my ($self, $table) = @_;
104 return $self->next::method(uc $table);
108 my ($self, $table) = @_;
110 my $rels = $self->next::method(uc $table);
112 foreach my $rel (@$rels) {
113 $rel->{remote_table} = lc $rel->{remote_table};
119 sub _columns_info_for {
120 my ($self, $table) = @_;
121 return $self->next::method(uc $table);
124 sub _extra_column_info {
125 my ($self, $info) = @_;
128 my ($table, $column) = @$info{qw/TABLE_NAME COLUMN_NAME/};
130 my $dbh = $self->schema->storage->dbh;
131 my $sth = $dbh->prepare_cached(
134 FROM all_triggers ut JOIN all_trigger_cols atc USING (trigger_name)
135 WHERE atc.table_name = ? AND atc.column_name = ?
136 AND column_usage LIKE '%NEW%' AND column_usage LIKE '%OUT%'
137 AND trigger_type = 'BEFORE EACH ROW' AND triggering_event LIKE '%INSERT%'
141 $sth->execute($table, $column);
142 if ($sth->fetchrow_array) {
143 $extra_info{is_auto_increment} = 1;
151 L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
152 L<DBIx::Class::Schema::Loader::DBI>
156 TSUNODA Kazuya C<drk@drk7.jp>
158 Dagfinn Ilmari Mannsåker C<ilmari@ilmari.org>