Re: the return of tables ()

Tim Bunce <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel
Message-ID <[email protected]>
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.
Or you could implement a custom quote_identifier() method.

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