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:

> > > 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.
> Or you could implement a custom quote_identifier() method.

This worked:
--8<---
sub quote_identifier
{
    my ($dbh, @arg) = map { defined $_ && $_ ne "" ? $_ : undef } @_;
    return $dbh->SUPER::quote_identifier (@arg);
    } # quote_identifier
-->8---

-- 
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.