Re: the return of tables ()

"H.Merijn Brand" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel
Message-ID <[email protected]>
On Tue, 2 Sep 2008 11:01:37 +0100, Tim Bunce <[email protected]>
wrote:

> On Tue, Sep 02, 2008 at 12:39:41AM +0200, H.Merijn Brand wrote:
> > On Mon, 1 Sep 2008 22:59:24 +0100, Tim Bunce <[email protected]>
> > wrote:
> > 
> > > > > > > > As get_info (29) now returns a TRUE value, the 'tables ()' method is
> > > > > > > > using a different strategy to build the list it returns:
> > > > > > > > 
> > > > > > > >     sub tables
> > > > > > > >     {
> > > > > > > >         my ($dbh, @args) = @_;
> > > > > > > >         my $sth    = $dbh->table_info (@args[0..4]) or return;
> > > > > > > >         my $tables = $sth->fetchall_arrayref or return;
> > > > > > > >         my @tables;
> > > > > > > > »       if ($dbh->get_info (29)) { # SQL_IDENTIFIER_QUOTE_CHAR
> > > > > > > > »           @tables = map { $dbh->quote_identifier (@{$_}[0,1,2]) } @$tables;
> > > > > > > > »           }
> > > 
> > > > > > > > Unify has no support for CATALOG's, so the values in info are not
> > > > > > > > defined, but still used in the map, causing all my tables no showing up
> > > > > > > > with and empty "". in front of it, which is illegal to the database :(
> 
> > > I wasn't very clear (and was actually partly misleading). Sorry.
> > > 
> > > What I meant was that the TABLE_CAT and/or TABLE_SCHEM columns in the
> > > data returned by your table_info () method are probably empty strings but
> > > should be undefs.
> > > 
> > > What does
> > >     Data::Dumper::Dumper($dbh->table_info(...)->fetchall_arrayref)
> > > show for an example table?
> > 
> > $ perl -Iblib/{lib,arch} -MPROCURA::DBD -MData::Dumper
> > -wle'$dbh=DBDlogon;print Dumper $dbh->table_info(undef,"PROLEP","parm")->fetchall_arrayref' $VAR1 = [
> >           [
> >             '',
> >             'PROLEP',
> >             'parm',
> >             'T',
> >             'W'
> >           ]
> >         ];
> > 
> > Correct, as that is the result of
> > 
> > sub table_info
> > {
> 
> >     my $sth = $dbh->prepare (
> > 	"select '', OWNR, TABLE_NAME, TABLE_TYPE, RDWRITE ".
> > 	"from   SYS.ACCESSIBLE_TABLES ".
> > 	$where);
> 
> > select NULL, OWNR, ...
> > 
> > is not allowed. I don't see an easy way out
> > 
> > sql> select NULL, OWNR, TABLE_NAME
> > sql>    from SYS.ACCESSIBLE_TABLES
> > sql>    where TABLE_NAME like 'parm';
> > NULL is not allowed in a constant list (-10518).
> 
> Perhaps you could use some expression that happens to yield a NULL.

I tried, I cannot without creating a new table, and that feels like
shooting a mouse with an elefant;

> Or you could implement a custom quote_identifier () method.

I could, but that would feel very unsafe

-- 
H.Merijn Brand          Amsterdam Perl Mongers  http://amsterdam.pm.org/
using & porting perl 5.6.2, 5.8.x, 5.10.x, 5.11.x on HP-UX 10.20, 11.00,
11.11, 11.23, and 11.31, SuSE 10.1, 10.2, and 10.3, AIX 5.2, and Cygwin.
http://mirrors.develooper.com/hpux/           http://www.test-smoke.org/
http://qa.perl.org      http://www.goldmark.org/jeff/stupid-disclaimers/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.