PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Knut Behrends <knb at gfz-potsdam dot de>
Subject: problems porting Sybase::BCP to Sybase::BLK
Date: Nov 16 2006 4:14PM

I am porting a script that uses Sybase::BCP to bcp-in some short tables
into a ASE 12.5
The transfer is from MSSQL-2000 to Sybase ASE. I am not pumping in text
files.

The old script works automagically well except for long strings of
length > 255 chars. I think this is a problem of BCP-in based on dblib.

Now I want to revise the script and port it to Sybase::BLK

What must I do to get a command similar to dbcmd() to work with Sybase BLK?

Any help is appreciated.

Best regards, Knut

#####
##### OLD - works reasonably well
#####
my $bcp = new Sybase::BCP $user, $pwd, $server;
$bcp->dbcmd("set char_convert iso_1 ") ;
$bcp->dbcmd("set identity_insert $mydb..$tg on") if (exists
$contbl1{$tg}  );
$bcp->config(INPUT => sub { $_ = shift @dat || last; return @{$_}} ,
OUTPUT => "$mydb.dbo.$tg", FIELDS => scalar(@FieldNames) );	
$bcp->run() ;
$bcp->dbcmd("set identity_insert $mydb..$tg off") if (exists
$contbl1{$tg} );


#####
##### NEW
#####
my $bcp = new Sybase::BLK $user, $pwd, $server;
## DOES NOT WORK
#$bcp->ct_sql("set char_convert iso_1 ");
# DOES NOT WORK
$bcp->ct_sql("set identity_insert $mydb..$tg on") if ( exists
$contbl1{$tg}  );
#$bcp->config(HAS_INDENTITY => 0);

# WORKS OK for tables without identity columns
$bcp->config( INPUT => sub { $_ = shift @rows || last; return @{$_} },
ERRORS => ('G:\_svncode\scripts\trunk\blk.err.' . $tg. "." . time()) ,
OUTPUT => "$mydb.dbo.$tg", TAB_INFO => \@fieldnames, NULL => qq{undef} );
$bcp->run();
$bcp->ct_sql("set identity_insert $mydb..$tg off") if ( exists
$contbl1{$tg} );


#####
##### ERROR messages - how can I get rid of these?
#####

Use of uninitialized value in pattern match (m//) at
C:\Perl\site\lib/Sybase/BLK.pm line 545.
Use of uninitialized value in length at C:\Perl\site\lib/Sybase/BLK.pm
line 545.

#### This refers to these lines in Sybase/BLK.pm
	    # Check for nulls:
            if(defined($null_pattern) && length($null_pattern) > 0 &&
               $data[$i] =~ /$null_pattern/)
	    {
		$data[$i] = undef;
	    } elsif(length($data[$i]) == 0) {
		# default NULL handling.
		$data[$i] = undef;
	    }

	
#### it is different from Sybase::BCP, why is there no \Q ... \E  anymore?
	    if(defined($null_pattern) && length($null_pattern) > 0 &&
	       $data[$i] =~ /\Q$null_pattern\E/)
	    {
		$data[$i] = undef;
	    }
	


$null_pattern should be initialised, as I am Passing in something.