|
|
sybperl-l Archive
Up Prev Next
From: Saso Tavcar <saso at select-tech dot si>
Subject: how to insert images
Date: May 12 1998 1:33PM
Hello!
I want to copy data from one table to tabele on another server.
I get an error:
DB-Library error:
Attempt to convert data stopped by syntax error in source field.
# log to source server
$dbh = Sybase::DBlib->dblogin($user, $password, $server, $appname);
$dbh->dbuse($database);
# limit the IMAGE fields to 1Mb (default is 32k)
$dbh->dbsetopt(DBTEXTSIZE, 10000000);
$dbh->dbcmd("select oid, history, format, image, timestamp from $table");
$dbh->dbsqlexec;
$dbh->dbresults;
# log to destination server and prepare for BCP
BCP_SETL(TRUE);
$dbh1 = Sybase::DBlib->dblogin($bcp_user, $bcp_password, $bcp_server, $appname);
$dbh1->bcp_init("$database\.\.$table", '', '', DB_IN);
$dbh1->bcp_meminit(5);
$count = 0;
while(@data = $dbh->dbnextrow)
{ ($oid, $history, $format, $image, $timestamp) = @data;
$dbh1->bcp_sendrow(\@data);
# Commit data every 10 rows.
if((++$count % 10) == 0) {
$dbh1->bcp_batch;
}
}
$dbh1->bcp_done;
$dbh1->dbclose;
$dbh->dbclose;
dbexit;
|