PERL DBI data_sources and syscdr database
Posted in 2014
Jacob Salomon found DBI->data_sources for Informix omitted syscdr and later discovered it returned at most 100 of the server's 168 databases. Setting MaxRows in an attr hash did not change this and some call forms gave a usage error. Justin Killen suggested contacting the module author, John Leffler, directly. No fix was found in the thread.
Auto-generated by Claude from the posts below — may be imperfect; read the full thread.
Topics: Connectivity: ODBC / JDBC / .NET
Greetings. I am staring to play with the DBI/DBD interface, trying to go by the book rather than just copying someones code. Chapter 4 gives this script for finding data sources; I would use that to get the connection strings to connect to a database in another Perl program. Here's the code: #!/usr/bin/perl # data_sources.pl - DBI exercise to play with database sources # use strict; use Carp; use DBI; my @drivers = DBI->available_drivers(); die "No DBI drivers found" unless (@drivers); foreach my $driver (@drivers) { my @data_sources = DBI->data_sources($driver); my $n_sources = @data_sources; printf("Driver: <%s> found with %s data sources\\ ", $driver, $n_sources); foreach my $data_source (@data_sources { printf("\\\\tData source: <%s>\\ ", $data_source); } } (HMMmmm I this editing box erases indenting spaces and adds line feeds.) I noticed that the output included these standard system databases: Data source: <dbi:Informix:onpload@prodserver_1> Data source: <dbi:Informix:sysmaster@prodserver_1> Data source: <dbi:Informix:sysuser@prodserver_1> Data source: <dbi:Informix:sysutils@prodserver_1> (Yes, I changed the actual server names to protect my client.) Missing from the list of databases (as data_sources): Informix:syscdr Since this is a server that uses ER heavily and has an extensive syscdr database, I'm wondering what's going on. Has anyone else ever noticed this database missing from the DBI data_sources? (Anybody else care? :-) Thanks. -- Jacob S
Hi again, folks. I just realized, as I test every little addition to the code, that the DBI->data_sources() function skipped a lot more than syscdr. It happens that this server has 168 databases, including the administrative databases like sysmaster and syscdr. However, the function appears to return a maximum of 100 data sources. So the missing syscdr is in plenty of company. As I type this I am looking throughthe source code to DBI.pm. (I don't know beans about how this module is put together.) But if I find that limit I will post my finding and very timidly raise that limit. (After backing up the file, of course!) Thoughts? Ideas that might speed up my quest for a solution? Someone actually know what to tweak? Perhaps that not-too-well second parameter, the \\\\%attr mentioned in the POD to DBI.pm? Thanks for reading - I'm guessing one of the readers thought of this and I just picked up the vibes. Of course, that *MUST* be it. ;-) Jacob S.
Folks, My pattern has been that if I ask the question, I stand a good chance of coming with the answer myself. Still not an excuse for ignoring me <kvetch, sob> but here's what I found: There the function data_sources() should be accessing that attr hash I mentioned in my previous post. I have found in code in DBM.pm that accesses $attr->{MaxRows} so I inserted this into my code: my %attr = (MaxRows=>20000); and tried a few variations of the call to DBI->data_sources(): - my @data_sources = DBI->data_sources($driver, \\\\%attr); # Still 100 rows - my @data_sources = DBI->data_sources($driver,,, \\\\%attr); # Same 100 rows - my @data_sources = DBI->data_sources($driver,"","", \\\\%attr); # Error below: DBI data_sources: invalid number of arguments: got handle + 3, expected handle + between 0 and 1 The complete error text is: Usage: $h->data_sources([\\\\%attr]) at /usr/local/lib/perl5/site_perl/5.8.7/sun4-solaris-64/DBI.pm line 1007. at /usr/local/lib/perl5/site_perl/5.8.7/sun4-solaris-64/DBI.pm line 1007 DBI::data_sources('DBI', 'CSV', '', '', 'ARRAY(0x100434660)') called at /nas/scripts/data_sources.pl line 17 BTW, in all of the above, I have also tried [\\\\%attr], as indicated by the rest of the error message. What have I missed? Thanks. -- Jacob S. (Getting well into Informix geek territory! :-)
I'd suggest contacting the module author (John Leffler) directly. His contact info is listed on cpan (http://search.cpan.org/~johnl/). He posts here from time to time, but you're probably more likely to get a response if you ask him directly. -Justin > -----Original Message----- > From: ids-bounces@iiug.org [mailto:ids-bounces@iiug.org] On Behalf Of > JACOB SALOMON > Sent: Wednesday, May 07, 2014 1:36 PM > To: ids@iiug.org > Subject: Re: PERL DBI data_sources and syscdr database [32958] > > Folks, > My pattern has been that if I ask the question, I stand a good chance of > coming with the answer myself. Still not an excuse for ignoring me > <kvetch, > sob> but here's what I found: > > There the function data_sources() should be accessing that attr hash I > mentioned in my previous post. I have found in code in DBM.pm that > accesses > $attr->{MaxRows} so I inserted this into my code: > > my %attr = (MaxRows=>20000); > > and tried a few variations of the call to DBI->data_sources(): > - my @data_sources = DBI->data_sources($driver, \\\\%attr); # Still 100 rows > > - my @data_sources = DBI->data_sources($driver,,, \\\\%attr); # Same 100 rows > > - my @data_sources = DBI->data_sources($driver,"","", \\\\%attr); # Error > below: > DBI data_sources: invalid number of arguments: got handle + 3, expected > handle > + between 0 and 1 > > The complete error text is: > Usage: $h->data_sources([\\\\%attr]) at > /usr/local/lib/perl5/site_perl/5.8.7/sun4-solaris-64/DBI.pm line 1007. > at /usr/local/lib/perl5/site_perl/5.8.7/sun4-solaris-64/DBI.pm line 1007 > > DBI::data_sources('DBI', 'CSV', '', '', 'ARRAY(0x100434660)') called at > /nas/scripts/data_sources.pl line 17 > > BTW, in all of the above, I have also tried [\\\\%attr], as indicated by the > rest > of the error message. > > What have I missed? > > Thanks. > > -- Jacob S. (Getting well into Informix geek territory! :-) > > > ************************************************************************** > ***** > Forum Note: Use "Reply" to post a response in the discussion forum.