Hi,
to use DBIx-Recordset 0.25a with DBD-Oracle 1.15 I must done some
fixes (patch attached):
1. see http://www.mail-archive.com/[EMAIL PROTECTED]/msg21302.html
2. to make test.pl compatible with perl >= 5.6 (two necessary changes
was done from 0.24 to 0.25a, but not all)
3. for one changed test the expected result was only adapted for
databases for which $EmptyIsNull is not true
4. the cleanup after the test does not work, because $dbh can't be
used any more at this point, because the db-handle will be disconnected
some line above:
$db = undef ;
by DBIx::Database::DESTROY()
5. some cosmetics, e.g. deprecated $#tabs < 0
I hope that all, except the cosmetics, will be integrated in the next
release.
IMO it would be good idea if DBI would be offer an additional method
like user_tables() or schema_tables() which uses in DBD-Oracle the
SQL code which I put to DBIx::Compat where it strictly speaking does
not belong.
regards, Silvio
diff -u1 Compat.pm~ Compat.pm
--- Compat.pm~ Tue Jan 20 21:11:29 2004
+++ Compat.pm Tue Jun 22 14:52:12 2004
@@ -73,4 +73,2 @@
-
-
sub ListFields
@@ -107,3 +105,16 @@
- return $hdl -> tables ;
+ my $qic = $hdl->get_info(29);
+
+ if ($qic)
+ {
+ return map { join '.',
+ map { s/^${qic}(.+)${qic}$/$1/ &&
+ s/${qic}${qic}/${qic}/g; $_
+ } split '\.'
+ } $hdl -> tables ;
+ }
+ else
+ {
+ return $hdl -> tables ;
+ }
}
@@ -115,3 +126,3 @@
- return grep (!/^MSys/, $hdl -> tables) ;
+ return grep !/^MSys/, ListTables($hdl) ;
}
@@ -125,6 +136,6 @@
- eval { @tabs = $hdl -> tables } ;
+ eval { @tabs = ListTables($hdl) } ;
# try the _ListTables function for DBD::mysql before 1.21..
- @tabs = $hdl -> func('_ListTables' ) if ($#tabs < 0 || $@) ;
+ @tabs = $hdl -> func('_ListTables' ) if (@tabs == 0 || $@) ;
@@ -135,16 +146,37 @@
- {
-
- my $hdl = shift;
+ {
+ my $hdl = shift;
- my @tabs = ListTablesFunc ($hdl) ;
+ my @tabs = ListTablesFunc ($hdl) ;
-# die Dumper([EMAIL PROTECTED]);
+ return map { s/`//g; $_ } @tabs ;
+ }
- @tabs = map { s/`//g; $_ } @tabs;
+sub ListTablesOra
+ {
+ my $hdl = shift ;
-
- }
+ my $sql = <<'SQL';
+ SELECT synonym_name name
+ FROM all_synonyms
+ WHERE owner = 'PUBLIC'
+ AND table_owner not in ('SYS','SYSTEM','TUNE')
+ UNION
+ SELECT USER || '.' || table_name name
+ FROM user_catalog
+ ORDER BY 1
+SQL
+ $sql =~ s/^\s+//gm;
+
+ my $sth = $hdl->prepare($sql);
+
+ return ()
+ unless defined($sth) && $sth->execute();
+
+ my $lst = $sth->fetchall_arrayref or return ();
+
+ return map { $_->[0] } @{$lst};
+ }
@@ -165,3 +197,2 @@
-
sub ListTablesIfmx
@@ -185,3 +216,2 @@
-
sub LimitOffsetStrMySQL
@@ -196,2 +226,3 @@
+
sub MysqlGetSerial
@@ -230,3 +261,2 @@
-
sub InformixGetSerial
@@ -429,2 +459,3 @@
# string where a number expected
+ 'ListTables' => \&ListTablesOra,
'QuoteTypes' => {
@@ -452,3 +483,2 @@
'QuoteIdentifier' => '""', # DBMS can handle idntifiers
with spaces by quoteing them.
-## 'ListFields' => \&SelectFieldsQuoted, # Use Select to get field
names
},
diff -u1 test.pl~ test.pl
--- test.pl~ Tue Dec 30 02:30:33 2003
+++ test.pl Tue Jun 22 17:15:47 2004
@@ -475,3 +475,3 @@
- $dbh = DBI->connect ("$DSN",$User, $Password) or die "Cannot connect to $DSN
($DBI::errstr)" ;
+ $dbh = DBI->connect ($DSN, $User, $Password) or die "Cannot connect to $DSN
($DBI::errstr)" ;
@@ -1463,3 +1463,3 @@
{
- Check ([1,3,4,5,7,8,9,10,11], ['id', 'name', 'txt'], [EMAIL PROTECTED]) or
print "ok\n" ;
+ Check ([4,7,8,9,10,11], ['id', 'name', 'txt'], [EMAIL PROTECTED]) or print
"ok\n" ;
}
@@ -3717,3 +3717,3 @@
{
- DBI::SQL_CHAR =>
+ DBI::SQL_CHAR() =>
[
@@ -3722,3 +3722,3 @@
],
- DBI::SQL_VARCHAR =>
+ DBI::SQL_VARCHAR() =>
[
@@ -3964,6 +3964,6 @@
- my $dbh = DBIx::Recordset -> SetupObject ({'!DataSource' => $dbh,
- '!Username' => $User, '!Password'
=> $Password
- });
-
+ my $dbh = DBIx::Recordset -> SetupObject ({'!DataSource' => $DSN,
+ '!Username' => $User,
+ '!Password' => $Password
+ });
DropTestTables($dbh, @Table);