ePages 6.15.1 - DE_EPAGES/ShopTransfer/API/BCP.pm

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
BCPInCommand
BCPInIterator
BCPOutStatement
BCPOutMapper
GetBcpParameter

Functions

BCPInCommand
BCPInIterator
BCPOutMapper
BCPOutStatement
GetBcpParameter

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
$FileName (string)
file name
$DBName (string)
database name (includes owner)
$Table (string)
table name
$Parameter (string)
special bcp parameter
Return
$BcpExitCode (integer)
exit code of bcp

BCPInIterator

Reads a bcp file and executes the cIterator on each row.

Syntax
BCPInIterator($FileName, $cIterator, $Encoding);
Example
BCPInIterator($FileName, sub { my @Row = @_; }, $Encoding));
Input
$FileName (string)
file name
$cIterator (perl)
perl function
$Encoding (string)
encoding of bcp file (default utf8)

BCPOutMapper

Read and Writes bcp files, all lines are converted via mapping.

Syntax
BCPOutMapper($SourceFileName, $TargetFileName, $cMap, $Encoding);
Input
$SourceFileName (string)
source file name
$TargetFileName (string)
source file name
$cMap (ref.code)
mapping function
$Encoding (string)
encoding of bcp file (default utf8)

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
$FileName (string)
file name
$sth (object)
DBD statement handle
$Encoding (string)
encoding of bcp file (default utf8)

GetBcpParameter

Read and Writes bcp files, all lines are converted via mapping.

Syntax
$Parameter = GetBcpParameter($Server, $User, $Password, $FilePath, $Encoding);
Input
$Server (string)
database server name
$User (string)
user name
$Password (string)
password to access the database
$FilePath (string)
path for debug and error log
$Encoding (string)
encoding of bcp file (default utf8)
Return
$Parameter (out} [filename]
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-n] [-c] [-t field_terminator] [-r row_terminator]
[-U username] [-P password] [-I interfaces_file] [-S server]
[-a display_charset] [-z language] [-v]
[-A packet size] [-J client character set]
[-T text or image size] [-E] [-g id_start_value] [-N] [-W] [-X]
[-M LabelName LabelValue] [-labeled]
[-K keytab_file] [-R remote_server_principal] [-C]
[-V [security_options]] [-Z security_mechanism] [-Q] [-Y]
[-x trusted.txt_file]
[--maxconn maximum_connections] [--show-fi] [--hide-vcc]
[--colpasswd [[[db_name.[owner].]table_name.]column_name [password]]]
[--keypasswd [[db_name.[owner].]key_name [password]]]
[--initstring ASE initialization string])
bcp parameter | string
usage: bcp [[db_name.]owner.]table_name[:slice_num] [partition pname] {in