Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 13 Jun 2003 @ 00:14:05 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


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



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023