Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Posts
    1

    Unanswered: bcp sendrow Error

    Hi ,
    I am using a perl program for loading bulk loading from a text File to the Sybase Table the Code is something like this.

    open(BCPINFILE, $FILE_OUT) || &usage ("Can't open $FILE_OUT: $!.");

    &bcp_init($dbproc , $temptable , '', 'bcp.err', $DB_IN) ||
    &usage ("bcp_init failed on $temptable $!.");

    &bcp_control ( $dbproc, 1, 0) || &usage ("bcp_control failed");

    my $firstrow = 1;
    my $delim = "|";
    my $ret = 0;

    while(<BCPINFILE>) {
    chop;
    my @brow = split /:/,$_ ;
    if ( $firstrow == 1 ){
    my $total_cols = @brow;
    $firstrow = 0;
    &bcp_meminit($dbproc, $total_cols) ||
    &usage ("bcp_meminit failed $!.");
    }
    if( &bcp_sendrow($dbproc, @brow) != SUCCEED)
    {
    <B><I># Print Errror Here ( Try to print the specific Error Message)</B></I>
    $ret = 3;
    }
    }

    The Program is working file when the Text File is ok . But if something is wrong in the Text File (like charctarter data in the intreger field) at the time of executing its giving a Error like this..

    DB-Library error:
    Attempt to convert data stopped by syntax error in source field.
    How do i capture the same in my Program and print it to a log file..

    Any help will be greatly apprecated..
    Regards
    Dev

  2. #2
    Join Date
    Jun 2003
    Posts
    140

    Re: bcp sendrow Error

    You can include -e parameter of BCP which routes errors to error
    log file, not sure how to implement in Perl though

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •