informix and perl
Posted in 1999
Topics: General Discussion
i need a good documentation that will explain to me how i can use perl to access data from informix. does anyone know any? peter
In article <36A4E6C9.7092C08B@mindspring.com>, Peter Choe <choepete@mindspring.com> wrote: > i need a good documentation that will explain to me how i can use perl > to access data from informix. does anyone know any? > > peter > > Peter: I picked away at the man pages on DBI and DBD and figured out the following. It's an example of how to connect to informix and retrieve records: The following utility displays db free space for IDS7.x. Hopefully you've configured the DBD and DBI perl modules for informix. Hopefully this can help you out: #!/usr/bin/perl use DBI; $~ = DBSPACE; $dbname = "sysmaster"; $drh = DBI->install_driver('Informix') or die "Problem Loading Driver\\n"; $dbh = DBI->connect("dbi:Informix:$dbname"); $stmt = "select dbs.name, sum(chk.chksize), sum(chk.nfree) " . "from sysdbspaces dbs, " . "syschktab chk " . "where dbs.dbsnum = chk.dbsnum " . "group by 1 " . "order by 1"; $sth = $dbh->prepare( $stmt ); $sth->execute; $numdbs = 0; while ( $rowref = $sth->fetch ) { @row = @{$rowref}; # Assign row fetched $chkname = $row[0]; $chksize = $row[1]; $chkfree = $row[2]; $chkperused = 100 - (($chkfree / $chksize) * 100); $chkmbfree = ($chkfree * 2048); $numdbs++; write; } $dbh->disconnect; #---------------------------------------------------------------------------- #-- Define Formats #---------------------------------------------------------------------------- format DBSPACE_TOP = DB-Space # Pages # Pages Free MByte's Free % Used --------------------------------------------------------------------------- . format DBSPACE = @>>>>>>>>>>>>>>>>> @########### @########### @############ @###.## $chkname, $chksize, $chkfree, $chkmbfree, $chkperused . -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own