Using Fastexport with DBD::Teradata

DBD::Teradata 2.2.0 provides improved support for Fastexport. Using Fastexport with DBD::Teradata requires some special considerations.

DBD::Teradata does not support recovery logging of utilities; i.e., you cannot PAUSE and then restart DBD::Teradata-based utility applications.

The attributes hash provided to tdat_UtilitySetup includes the following keys:

AttributeRequired ?Description
Utility Yes set to 'EXPORT'
SQL Yes A SELECT statement to be used for the export. Note that parameterized SELECTs, and multi-statement SELECTs have not yet been tested.
Target Yes can be set to either a subroutine reference, a file description.

A file description is specified as

< VARTEXT 'c' | INDICDATA | DATA > filename

where 'c' is the separator character. Use '|' for compatibility with the default Teradata VARTEXT file format. INDICDATA indicates a fastload formatted file with indicator bytes, and DATA indicates a fastload formatted file without indicator bytes.

Report No a subroutine reference which is called with a status message as the Fastexport progresses.
Sessions Yes the number of export sessions to use
Context No a hashref that can contain anything the application desires; it will be passed to the Source subroutine reference each time records are to be collected
MP No when set to a nonzero numeric value, or the string 'nothreads', causes multiple processes to be fork()'d, 1 per export session. When set to the string 'threads', causes multiple threads to be spawned, 1 per export session. This attribute may provide performance improvement on certain platforms (esp. multiprocessor platforms).
Retry No either a scalar or arrayref; if scalar, indicates the number of seconds to wait between retrying to start the fastexport in the event the prior attempt failed due to no remaining utility job slots available on the database. If an arrayref, the first element is the number of seconds between retries, and the second element is the maximum number of retry attempts. The scalar form will retry indefinitely.

Examples

Multijob MP Export with subroutine source


    my $ctldbh = DBI->connect('dbi:Teradata:dbc', $username, $password,
        { RaiseError => 0, PrintError => 0, tdat_lsn => 0 });

    my $total = $ctldbh->tdat_UtilitySetup(
        {
        Utility => 'EXPORT',
        Sessions => $sesscount,
        SQL => 'SELECT * FROM alltypetst',
        Report => \&report_cb,
        Target => \&save_data,
        Context => {
            Count => \$count,
            Runtime => \$mlstarted,
            Base => [ 0, 1000000 ]
            },
        MP => 1,
        Retry => [ 120, 3]	# retry every 2 minutes up to 3 times
        });

    print $ctldbh->errstr
        unless ($total && ($total > 0));

sub report_cb {
    my ($msg) = @_;
    print $msg, "\n";
}


Multithreaded MP Export with INDICDATA source


    my $ctldbh = DBI->connect('dbi:Teradata:dbc', $username, $password,
        { RaiseError => 0, PrintError => 0, tdat_lsn => 0 });

    my $total = $ctldbh->tdat_UtilitySetup(
        {
        Utility => 'EXPORT',
        Sessions => $sesscount,
        SQL => 'SELECT * FROM alltypetst',
        Report => \&report_cb,
        Source => 'INDICDATA rawdata.dat',
        MP => 'threads'
        });

    print $ctldbh->errstr
        unless ($total && ($total > 0));

Multijob MP Export with VARTEXT source


    my $ctldbh = DBI->connect('dbi:Teradata:dbc', $username, $password,
        { RaiseError => 0, PrintError => 0, tdat_lsn => 0 });

    my $total = $ctldbh->tdat_UtilitySetup(
        {
        Utility => 'EXPORT',
        Sessions => $sesscount,
        SQL => 'SELECT * FROM alltypetst',
        Report => \&report_cb,
        Source => "VARTEXT '|' vardata.txt",
        MP => 1
        });

    print $ctldbh->errstr
        unless ($total && ($total > 0));