Package DE_EPAGES::ShopTransfer::API::BCP
Helper functions for the shop transfer script. These functions export shop data from the database into text files, one file per database table. The file format is similar to CSV, but without quoting - therefore the field separator and record separator must never be included in the actual data. NULL values are represented by empty strings.
@EXPORT_OK |
Functions
BCPInCommand
Imports a file to database, the $Parameter can be build via GetBcpParameter.
Syntax |
$BcpExitCode = BCPInCommand($FileName, $DBName, $Table, $Parameter); |
Example |
$BcpExitCode = BCPInCommand($FileName, $DBName, $Table, GetBcpParameter($Server, $User, $Password, $FilePath, $Encoding)); |
Input |
|
Return |
|
BCPInIterator
Reads a bcp file and executes $Sub->(@Values) on each row.
Syntax |
BCPInIterator($FileName, $Sub, $Encoding); |
Example |
BCPInIterator($FileName, sub { my @Row = @_; }, $Encoding)); |
Input |
|
BCPOutMapper
Read and Writes bcp files, all lines are converted via mapping. Calls @NewValues = $Sub->(@Values) for each row. Deletes the row if the result of $Sub is an empty array.
Syntax |
BCPOutMapper($SourceFileName, $TargetFileName, $Sub, $Encoding); |
Input |
|
BCPOutStatement
Writes a bcp file, lines are rows of the result of statement.
Syntax |
BCPOutStatement($FileName, $sth, $Encoding); |
Example |
my $dbi = GetCurrentDBHandle(); my $dbh = $dbi->dbh; my $sth = $dbh->prepare('select * from object'); $sth->execute(); BCPOutStatement($FileName, $sth, $Encoding); $sth->finish(); |
Input |
|
CreateBCPFileIterator
Creates an iterator for reading a bcp file line by line.
Syntax |
$Iterator = CreateBCPFileIterator($FileName, $Encoding); |
Example |
$Iterator = CreateBCPFileIterator('table.txt'); print Dumper( $_ ) while <$Iterator>; |
Input |
|
Return |
|
GetBcpParameter
Read and Writes bcp files, all lines are converted via mapping.
Syntax |
$Parameter = GetBcpParameter($Server, $User, $Password, $FilePath, $Encoding); |
Input |
|
Return |
|