|
|
Archives of the TeradataForum
Message Posted: Thu, 15 May 2003 @ 15:41:54 GMT
Subj: | | Re: Inserting Explains into a Table |
|
From: | | Geoffrey Rommel |
| Does anyone know of a way to insert an 'Explain' statement into a table via V2R4.1.3? | |
FWIW, here's how I would do it....
#!/usr/bin/perl
#
use DBI;
### Set username & password in some way here...
#---------------------------------------------------------------------
# Main Body
# Unfortunately, two connections are needed for DBD::Teradata.
#---------------------------------------------------------------------
$dbh = DBI->connect("dbi:Teradata:dbccop1",$RUN_USERNM,$RUN_PASSWD)
or die "Could not connect to Teradata";
$dbh2 = DBI->connect("dbi:Teradata:dbccop1",$RUN_USERNM,$RUN_PASSWD)
or die "Could not connect to Teradata";
$sth = $dbh->prepare("explain select * from dbc.tables");
$sth->execute();
$i = 1;
while ( @row = $sth->fetchrow_array ) {
print "row (", scalar(@row),"): <@row>\n";
$ins = $dbh2->prepare("insert into lcidba.plan_table
values($i, '$row[0]')" );
$ins->execute();
$ins->finish();
$i++;
}
$sth->finish();
$dbh->disconnect;
| |