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: salvatore dot sferrazza at ny dot ubs dot com
Subject: BCP difficulties
Date: Oct 30 1997 4:40PM

     Greetings,
     
     Sybase 11.0.2, Sybase::DBlib, Perl 5.004
     
     I recently modified a script I wrote some time back, and the original 
     script works fine and is almost in production.  I needed to modify
     the script for a different project, and now I am getting the following
     errors when I try to run it:
     
     Server 'ERISDVLP', Line 1
             The front end tool you are using does not support the feature 
     of bulk insert from host, please use the proper tools for this 
     command.
     DB-Library error:
             General SQL Server error: Check messages from the SQL Server.
     DB-Library error:
             bcp_init() must be called before any other bcp routines.
     
     
     The last line get repeated several times until the script finally 
     dies.  Below is my main bcp routine.  This routine works in my 
     other script...any ideas/insight?  The line that bothers me the most 
     is the first one re: front-end tool.
     
     Thanks guys..
     
     -- Sal
     
      ################################################
     
     sub bcp_it {
     
         my $err_file = "./bcp.errors";
         my ($dbh, $tablename, $cols, $textfile) = @_;
         my $bcp_string = "corpdir_test" . ".dbo." . $tablename;
         my $delimiter = "\|";
             
         &BCP_SETL(TRUE);
     
         $dbh->bcp_init($bcp_string, undef, $err_file, DB_IN);
     
         $dbh->bcp_meminit($cols);
         
         open(DOWNLOAD, $textfile) || die "Fatal: couldn't open       
                $textfile.\n";
     
         while() {
     
        next if ($_ == "\n"); 
     
        chop;
         
        @data = split(/\Q$delimiter\E/);
     
        &exception (@data) if ($dbh->bcp_sendrow(@data) == FAIL);
     
        ++$count;
        
        if (($count % 1000) == 0) { $ret = $dbh->bcp_batch }
     
         }
     
         $ret = $dbh->bcp_done;
      
     }