DBD-Teradata
view release on metacpan or search on metacpan
doc/tdatdbd.html view on Meta::CPAN
my @dbhlist;
my @sthlist;
open(IMPORT "$infile") || die "Can't open import file";
binmode IMPORT;
for (my $i = 0; $i < 10; $i++) {
$dbhlist[$i] = DBI->connect("dbi:Teradata:dbc", "dbc", "dbc");
if (!defined($drh)) { $drh = $dbhlist[$i]->{Driver}; }
}
for (my $i = 0; $i < $sesscount; $i++) {
$sthlist[$i] = $dbhlist[$i]->prepare(
'USING (col1 INTEGER, col2 CHAR(30), col3 DECIMAL(9,2), col4 DATE) ' .
'INSERT INTO mytable VALUES(?, ?, ?, ?)', {
tdat_nowait => 1,
tdat_raw_in => IndicatorMode
});
sysread(IMPORT, $buffer, $len)) {
$sthlist[$i]->bind_param(1, $buffer);
$sthlist[$i]->execute();
}
while (sysread(IMPORT, $buffer, $len)) {
$i = $drh->func(\@dbhlist, -1, tdat_FirstAvailable);
$rowcnt = $sthlist[$i]->func(undef, tdat_Realize);
if (!defined($rowcnt)) {
print STDERR " ** INSERT failed: " . $sthlist[$i]->errstr() . "\n";
}
$sthlist[$i]->bind_param(1, $buffer);
$sthlist[$i]->execute();
}
while (some statements still active) {
$i = $drh->func(\@dbhlist, -1, tdat_FirstAvailable);
$rowcnt = $sthlist[$i]->func(undef, tdat_Realize);
if (!defined($rowcnt)) {
print STDERR " ** INSERT failed: " . $sthlist[$i]->errstr() . "\n";
}
$sthlist[$i]->finish();
}
</pre>
<a name="utilsetup"></a>
<h4>tdat_UtilitySetup<br>
<code>$i = $sth->tdat_UtilitySetup(\%utility_attributes);</code></h4>
As described in the <a href="#utilif">Utility</a> section, this function encapsulates
much of the processing for FASTLOAD, MLOAD, and EXPORT utility applications. The attributes
parameter includes the following attributes:
<p>
<table border=1 align=center>
<tr bgcolor='#FFEB99'><th>Attribute</th><th>Required/Optional</th><th>Default</th><th>Description</th></tr>
<tr><td align=center valign=top><b>Checkpoint</b></td><td align=center valign=top>Optional</td><td valign=top>1,000,000</td>
<td valign=top>Number of rows to process between checkpoints</td></tr>
<tr bgcolor='#E9E9E9'><td align=center valign=top><b>CheckpointCallback</b></td><td align=center valign=top>Optional</td><td valign=top>None</td>
<td valign=top>Ref to a subroutine to be called when a checkpoint event occurs</td></tr>
<tr><td align=center valign=top><b>Context</b></td><td align=center valign=top>Optional</td><td valign=top>None</td>
<td valign=top>Any value the application wishes to pass thru to the callbacks; most often
a hashref with various application specific control attributes</td></tr>
<tr bgcolor='#E9E9E9'><td align=center valign=top><b>ErrorLimit</b></td><td align=center valign=top>Optional</td><td valign=top>1,000,000</td>
<td valign=top>Maximum number of errors to allow before terminating a FASTLOAD or MLOAD</td></tr>
<tr><td align=center valign=top><b>LogTables</b></td><td align=center valign=top>Optional</td><td valign=top> </td>
<td valign=top>Arrayref of errortables for FASTLOAD or MLOAD</td></tr>
<tr bgcolor='#E9E9E9'><td align=center valign=top><b>Loopback</b></td><td align=center valign=top>Optional</td><td valign=top>None</td>
<td valign=top>Specifies a SQL SELECT statement to be used as the source of data for either
FASTLOAD or MLOAD utilities. This attribute will result in an EXPORT job being logged on,
and a matching EXPORT session generated for each FASTLOAD/MLOAD session to provide data.
Note that this attribute requires the <b>MP</b> attribute to be enabled.</td></tr>
<tr><td align=center valign=top><b>MP</b></td><td align=center valign=top>Optional</td><td valign=top>None</td>
<td valign=top>When set to a nonzero value, causes the utility to operate in multiprocess mode.
whereby a separate process is fork()'ed for each utility session. In some environments,
this can improve performance (esp. SMP platforms). Note that this mode is not yet
available on Windows platforms, due to issues with the fork() emulation as
implemented. MP can be used with <b>Microsoft Services for UNIX 3.0</b>, as it
provides a true fork() implementation.
</td></tr>
<tr bgcolor='#E9E9E9'><td align=center valign=top><b>Report</b></td><td align=center valign=top>Optional</td><td valign=top>None</td>
<td valign=top>A callback subroutine reference to receive status messages as the utility processing
progresses.</td></tr>
<tr>
<td align=center valign=top><b>RequestSize</b></td>
<td align=center valign=top>Optional<br><i>(FASTLOAD and MLOAD only)</i></td>
<td valign=top>64256</td>
<td valign=top>Maximum request buffer size in bytes. For Teradata versions V2R6.0 and above, this
value may be increased up to 1,048,000 in order to transfer a larger number of tuples to the database
in a single request. The value is silently ignored if less than 64256, or greater than 1,048,000, or the
Teradata version is below V2R6.0, or the connections are CLI adapter based.</td></tr>
<tr bgcolor='#E9E9E9'><td align=center valign=top><b>Sessions</b></td><td align=center valign=top>Optional</td><td valign=top>Lesser of number of AMPs<br>in the DBMS, or 24</td>
<td valign=top>Number of utility sessions to logon</td></tr>
<tr><td align=center valign=top><b>Source</b></td><td align=center valign=top>Required for FASTLOAD and MLOAD</td><td valign=top>None</td>
<td valign=top>May be a
<ul>
<li>Ref to a subroutine to be called to import data
<li>Filename description for either VARTEXT or FASTLOAD formatted files (see below)
<li>DBI connection handle of a control session to be used for the EXPORT job
when Loopback attribute is specified (see below).
</ul>
The filename description is <br>
<code>
< VARTEXT 'c' | INDICDATA | DATA > <i>filename</i>
</code><br>
where 'c' is the character to be used as a field separator.
</td></tr>
<tr bgcolor='#E9E9E9'><td align=center valign=top><b>SQL</b></td><td align=center valign=top>Required</td><td valign=top> </td>
<td valign=top>SQL statement to be applied (INSERT for FASTLOAD, SELECT for EXPORT, or an arrayref
of multiple statements for MLOAD); <br>
<b>NOTE:</b> Placeholder (i.e., '?' parameters) are not allowed.</td></tr>
( run in 1.210 second using v1.01-cache-2.11-cpan-39bf76dae61 )