Seeing as how all the necessary index information is in the system
tables, it shouldn't be all that hard to write a statistics_info
method...I'm sure patches would be gladly accepted :-)

-Doug

On Thu, Dec 17, 2009 at 5:49 AM, White, Richard L <rlwh...@illinois.edu> wrote:
> Martin,
>
> Thanks for your help.  I had been reading the documentation on the DBI module 
> and not the stuff on the DBD::Oracle driver.  You are correct, even the 
> newest one does not seem to support statistics_info.  You are also correct 
> that I'm not using the newest version of that driver.  The version I'm using 
> is the newest that is available on ActiveState.  Due to the fact that even 
> the newest one does not do what I need, I think I'll just stay with the 
> version I have.  Unless I can find the ODBC Oracle data source driver for 
> free, I guess I will have to remove this from the project.
>
> Thanks
>
> Rich White
> Service Manager -- Illinois Compass
> University of Illinois at Urbana-Champaign
>
> -----Original Message-----
> From: Martin J. Evans [mailto:martin.ev...@easysoft.com]
> Sent: Wednesday, December 16, 2009 1:12 PM
> To: White, Richard L
> Cc: dbi-users@perl.org
> Subject: Re: Problem with method statistics_info
>
> White, Richard L wrote:
>> Hi,
>>
>> I'm new to the list, but not to Perl.  I can not find an answer to my 
>> current coding problem.
>> Is there an archive of this list?
>>
>> I'm running this code on:
>> OS - Windows XP
>> DB - Oracle 10 on Solaris
>>
>> I reinstalled ActiveState Perl yesterday and now have:
>> Perl - 5.10.1
>> DBI -- 1.609
>> DBD-ODBC - 1.23
>> DBD-Oracle - 1.21
>>
>>
>> This is a section of my current code that is not working.
>> The "statistics_info" method leaves the $sth variable undefined.
>> The table I'm looking at does have indexes with about one half of them being 
>> unique.
>> If I change the code to use the "foreign_key_info" line I get the expected 
>> results.
>> What do I have wrong with the "statistics_info" line?
>>
>> my $dbh = 
>> DBI->connect("dbi:Oracle:host=$db_sys;sid=$db_sid",$db_user,$db_pass);
>> $dbh->{RaiseError} = 1;
>>
>> #my $sth = $dbh->foreign_key_info ('',$db_schema,$db_table,'','','');
>> my $sth = $dbh->statistics_info ('',$db_schema,$db_table,'1','1');
>>
>> my $array_ref = $sth->fetchall_arrayref();
>>
>> $dbh->disconnect;
>>
>>
>> Rich White
>> Service Manager -- Illinois Compass
>> University of Illinois at Urbana-Champaign
>>
>>
>
> Argh, you got me there, I did not read your email carefully enough and
> saw DBD::ODBC then realised you are actually running DBD::Oracle.
> Thought I'd send you what I'd written anyway. I'm not certain
> DBD::Oracle does statistics_info but if it doesn't and John Scoles wants
> the queries we use to Oracle procedures to generate statistics output I
> can probably dig them out.
>
> ODBC can be a bit funny about empty strings in the database and schema
> fields so I'd try with undef. When I run this to SQL Server with:
>
> create table martin (a int);
> create unique index martin_ui on martin(a);
>
> use DBI;
> use strict;
> my $h = DBI->connect('dbi:ODBC:baugi', 'sa', 'easysoft');
> my $sth = $h->statistics_info ('','','MARTIN','1','1');
> DBI::dump_results($sth);
>
> I get:
>
> 'master', 'dbo', 'martin', undef, undef, undef, '0', undef, undef,
> undef, '0', '0', undef
> 'master', 'dbo', 'martin', '0', 'martin', 'martin_ui', '3', '1', 'a',
> 'A', undef, undef, undef
> 2 rows
>
> so it does work. I don't have this setup on Windows at home and I don't
> have Oracle's or Microsoft's Oracle ODBC driver anyway.
>
> BTW, your DBD::Oracle is out of date, 1.23 is the current version.
>
> Martin
>

Reply via email to