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: mpeppler at itf dot ch (Michael Peppler)
Subject: Re: BCP and index drop Questions
Date: Feb 27 1996 12:50PM

> >To check if you've actually patched DBlib.xs, edit the file and check
> 
> >that around lines 3690-3707 you have a line that reads:
> 
> They're there. 
> 
> let me know what you find out.  I really wish I had time to check through 
> the code and figure this out on my own, but I just don't.  I got to many 
> things going on at once.
> 
> Thanks for your help.  It's appreciated.

Actually the patch was not needed :-) (but doesn't hurt...)

The problem was sending T-SQL code after calling bcp_init(). Moving the
'drop index' commands to before the bcp_init() solves the problem:

sub data_bcp {
   local (*Indices, $Table, $FileName) = @_;
   local ($Cnt, @dat, $Index, $SybSess);

    &BCP_SETL(&Sybase::DBlib::TRUE);

# put appropriate values for user, password, etc....
    $SybSess = Sybase::DBlib->dblogin(user, password, server);
    $SybSess->dbuse(database);

    foreach $Index (@Indices) {
       $sqlStr = "drop index $Table.$Index";
       $SybSess->sql($sqlStr);
    }
    $SybSess->bcp_init('BugTrack.dbo.JMMember', undef, "bcp.err", DB_IN);
    $SybSess->bcp_meminit(14);

    open(BCP_DATA, "bcp.dat") || die "Unable to open bcp.dat for reading";

    $Cnt = 0;
    while () {
        chop;
        @dat = split(/\t/);
        die "bcp_sendrow failed at row $Cnt" if ($SybSess->bcp_sendrow(@dat) == FAIL);
        ++$Cnt;

        if (($Cnt % 100) == 0) {
            $Rows = $SybSess->bcp_batch;
            print "$Rows Rows Sent to Sybase Server\n";
        }
    }
    $Rows = $SybSess->bcp_done;
    print "$Rows rows Total Sent to Sybase Server\n";

    close BCP_DATA;

    foreach $Index (@Indices) {
       $sqlStr = "create Index $Index on $Table($Index)";
       $SybSess->sql($sqlStr);
    }
}


Michael