hello,
i wrote this perl script to bcp out a table from a source database and bcp in to a target database table... this perl script does not require a sybase module... this also assumes that you are using ASE 12.0... if not, just change the bin path in the script... try something like this just change the bcp out line to dump and bcp in line to load...
#! /usr/bin/perl
#
## USE THE MODULES NEEDED FOR THIS PROGRAM.
#
use FileHandle;
#
## ARGUMENTS
#
while ($#ARGV >= 0)
{
($_, $val) = getArgument($ARGV[0]);
SWITCH:
{
if (/^sourceDatabase$/) { $db1 = $val; last SWITCH }
if (/^sourceTable$/) { $table1 = $val; last SWITCH }
if (/^sourceUser$/) { $user1 = $val; last SWITCH }
if (/^sourcePassword$/) { $password1 = $val; last SWITCH }
if (/^sourceServer$/) { $server1 = $val; last SWITCH }
if (/^targetDatabase$/) { $db2 = $val; last SWITCH }
if (/^targetTable$/) { $table2 = $val; last SWITCH }
if (/^targetUser$/) { $user2 = $val; last SWITCH }
if (/^targetPassword$/) { $password2 = $val; last SWITCH }
if (/^targetServer$/) { $server2 = $val; last SWITCH }
if (/^out$/) { $outPath = $val; last SWITCH }
}
shift ARGV;
}
#
## RUN BCP OUT.
#
system (`/usr/sybase/OCS-12_0/bin/bcp $database1..$table1 out $outPath/$table.dat -U$user1 -P$password1 -S$server1 -c -t "|" -r "\n"`);
#
## TRUNCATE THE TABLE.
#
system (`/usr/sybase/OCS-12_0/bin/isql -U$user2 -P$password2 -S$server2 -o$outPath/truncate$table2.out`);
#
## RUN BCP IN.
#
system (`/usr/sybase/OCS-12_0/bin//bcp $database2..$table2 in $outPath/$table2.dat -U$user2 -P$password2 -S$server2 -b20000 -c -t "|" -r "\n"`);
#
## SUBROUTINE.
#
sub getArgument
{
return split(/=/, $_[0]);
}
-----------
here's the usage:
MyScriptName.pl sourceDatabase=MySourceDatabaseName sourceTable=MySourceTableName sourceUser=sa sourcePassword=MySourcePassword sourceServer=MySourceServerName targetDatabase=MyTargetDatabaseName targetTable=MyTargetTableName targetUser=sa targetPassword=MyTargetPassword targetServer=MyTargetServerName out=MyOutputPath <ENTER>
let me know if it works...
hth,
q.