Maybe someone would like to see this - Here is a perl program performing
runstats dynamically. Same concept as from Windows, the node/database
must be cataloged locally (wherever the script runs).
#!/usr/bin/perl
use DBI;
$now = `/bin/date "+%m%d%y_%H%M"`;
chop($now);
$logfile = "/home/zzz/zzz/log/runstats" . $now . ".log";
open (STDERR, ">>$logfile");
open (STDOUT, ">>$logfile");
$database='dbi:DB2:<ur db name>';
$sql = "SELECT 'RUNSTATS ON TABLE '||RTRIM(CREATOR)||'.'||NAME||' ON ALL
COLUMNS WITH DISTRIBUTION ON ALL COLUMNS '||
'DEFAULT NUM_FREQVALUES 20 NUM_QUANTILES 20 AND DETAILED INDEXES ALL
ALLOW WRITE ACCESS;' FROM SYSIBM.SYSTABLES WHERE TYPE = 'T' ORDER BY
CREATOR, NAME";
$db = DBI->connect($database, '<auth id>', '<pswrd>')
or die "Connect failed! $database: $DBI::errstr";
$sth = $db->prepare($sql);
$sth->execute();
`/home/zzz/sqllib/bin/db2 connect to <ur db name>`;
while (@row = $sth->fetchrow_array)
{
$result = `/home/zzz/sqllib/bin/db2 $row[0]`;
print "$result";
}
$sth->finish;
$db->disconnect();
close(STDERR);
close(STDOUT);
-----Original Message-----
From: bimal tandel
[mailto:db2udbdba-ezmlmshield-x45380654.[Email address protected]
Sent: Monday, October 25, 2004 3:47 PM
To: LazyDBA Discussion
Subject: Re: Runstats from Windows
The steps involved to do this is
1. Catalog the Tcpip node. To do this you will need the hostname and the
portnmber of the instance.
2. Catalog the database at that node. You will need the database name.
3. Connect to the database using the connect command.
4. Execute runstats command.
Regards
----- Original Message -----
From: "Dar " <db2udbdba-ezmlmshield-x42003819.[Email address protected]
To: "LazyDBA Discussion" <[Email address protected]
Sent: Monday, October 25, 2004 2:17 PM
Subject: Runstats from Windows
> Hi,
>
> I am trying to execute runstats on an AIX 5.2 DB2 v8 server remotely
from
> a VB app within Windows. Does anyone know how this is done please?
>
>
>
>
> ---------------------------------------------------------------------
> PLEASE CLICK REPLY-ALL TO SEND A REPLY TO EVERYONE
> website: http://www.LazyDBA.com
> To unsubscribe: http://www.lazydba.com/unsubscribe.html
>
>
---------------------------------------------------------------------
PLEASE CLICK REPLY-ALL TO SEND A REPLY TO EVERYONE
website: http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
DB2 & UDB email list listserv db2-l LazyDBA home page