| 1 | package DBIO::Oracle::Introspect::Tables; | ||||||||||
| 2 | # ABSTRACT: Introspect Oracle tables and views | ||||||||||
| 3 | |||||||||||
| 4 | 29 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 29 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 29 | our $VERSION = '0.900007'; | |||||||||
| 8 | |||||||||||
| 9 | |||||||||||
| 10 | |||||||||||
| 11 | 2 | ▶ | sub fetch { | ||||||||
|
Subroutine
fetch: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 12 | 2 | my ($class, $dbh, $schema) = @_; | |||||||||
| 13 | |||||||||||
| 14 | 2 | my %tables; | |||||||||
| 15 | |||||||||||
| 16 | # Fetch tables from all_tables (owned tables) | ||||||||||
| 17 | 2 | my $sth = $dbh->prepare(q{ | |||||||||
| 18 | SELECT * FROM ( | ||||||||||
| 19 | SELECT table_name, 'table' AS kind | ||||||||||
| 20 | FROM all_tables | ||||||||||
| 21 | WHERE owner = ? | ||||||||||
| 22 | AND table_name NOT LIKE 'BIN$%' | ||||||||||
| 23 | AND table_name NOT LIKE 'DR$%' | ||||||||||
| 24 | UNION ALL | ||||||||||
| 25 | SELECT view_name, 'view' AS kind | ||||||||||
| 26 | FROM all_views | ||||||||||
| 27 | WHERE owner = ? | ||||||||||
| 28 | ) | ||||||||||
| 29 | ORDER BY NLSSORT(table_name, 'NLS_SORT=BINARY') | ||||||||||
| 30 | }); | ||||||||||
| 31 | 2 | $sth->execute($schema, $schema); | |||||||||
| 32 | |||||||||||
| 33 | 2 | ▶ | while (my $row = $sth->fetchrow_hashref('NAME_lc')) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | $tables{ $row->{table_name} } = { | ||||||||||
| 35 | table_name => $row->{table_name}, | ||||||||||
| 36 | kind => $row->{kind}, | ||||||||||
| 37 | 2 | schema => $schema, | |||||||||
| 38 | }; | ||||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 2 | return \%tables; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 29 | 1; | |||||||||
| 45 | |||||||||||
| 46 | __END__ | ||||||||||