in reply to Re^3: Sybase::BCP
in thread Sybase::BCP

I did a bcp of the file (/tmp/css.txt) into the DB from the Unix command line & the file loaded properly, all 63 rows as they should be. This was walking through the interactive BCP utility, and I saved off the format file it created.

When I use the perl script with Sybase::BCP, then isql from the command line to do "select * from tmp_site_term" all I see are NULLS in both columns.

Thanks.

Replies are listed 'Best First'.
Re^5: Sybase::BCP
by mpeppler (Vicar) on Nov 03, 2004 at 15:22 UTC
    OK - two more things for you to test:

    First, try the same thing with Sybase::BLK instead of Sybase::BCP. BLK uses the CT-lib based API which is required if your target table has any new features (such as row-level locking). The Sybase::BLK module has the same syntax as Sybase::BCP.

    Second, try loading the data via bcp using this command line:

    bcp db..table in tmpfile -c -Uuser -Ppwd -Ssrv
    (obviously using correct values for "db", "table", etc.) That should mimic what Sybase::BLK will try to do (i.e. split on the tab and use \n for the row separator).

    Michael

    update Sybase::BLK is part of sybperl, so you should already have it installed...

      Well, the good news is that the bcp from the command line works fine... 63 rows of data loaded properly.

      The bad news is, we apparently do not have Sybase::BLK installed on our system. Changing my code to:
      use Sybase::BLK; $bcp = new Sybase::BLK $user, $pwd, $server, $appname; $bcp->config(INPUT => $tmp_file, OUTPUT => 'css..tmp_site_term', ERRORS => 'bcp_errors'); $bcp->run;
      I get an error: Can't locate Sybase/BLK.pm in @INC (@INC contains: /usr/perl5/5.00503/sun4-solaris /usr/perl5/5.00503 /usr/perl5/site_perl/5.005/sun4-solaris /usr/perl5/site_perl/5.005 .)

      Should I pursue using the other bcp routines?
        OK - so you appear to have an older version of sybperl installed that didn't include Sybase::BLK.

        At this point you have a couple of possibilities:

        • You can simply use the bcp binary to load the data.
        • If the file is not likely to become very big (say a couple of thousand rows) you could simply insert the data with a normal SQL insert.
        • You can try to get Sybase::BCP to work.
        Personally I'd probably just run bcp directly using something like
        system("bcp css..tmp_site_term in $tmp_file -c -U$user -P$pwd -S$serve +r -e$tmp_file.err");
        Michael