|
|
Archives of the TeradataForum
Message Posted: Thu, 13 Jun 2003 @ 00:14:05 GMT
Subj: | | Re: Perl Resources |
|
From: | | Dwight Etheridge |
This code loops through a list of tablenames suppled in stdin, and writes each one to a separate file. Columns of each export are
delimited with ~ (settable in the $TARG). This dbi version does its own file i/o, so I think that's why it supports delimited output
already.
use DBI;
use DBI qw(:sql_types);
use FileHandle;
use DBD::Teradata;
my $ctldbh = DBI->connect('dbi:Teradata:eqcop1', "userid", "mypass",
{ RaiseError => 0, PrintError => 0, tdat_lsn => 0 });
while (<>)
{
chomp;
my $tgttbl = $_ ;
my $tgttbl_e = "TI_$tgttbl.txt";
my $TARG = "VARTEXT '~' $tgttbl_e ";
my $total = $ctldbh->func(
{
Utility => 'EXPORT',
Sessions => '3',
SQL => "SELECT * FROM mydb.$tgttbl",
# Report => \&report_cb,
Target => $TARG,
MP => 0
},
tdat_UtilitySetup);
print $ctldbh->errstr
unless ($total && ($total > 0));
}
sub report_cb {
my ($msg) = @_;
print $msg, "\n";
}
--
Dwight Etheridge
Teradata Certified Master
| |