Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: "Wheelton, Gareth" <gareth dot wheelton at csfb dot com>
Subject: printing to a piped filehandle of sybase bcp
Date: Nov 21 2001 3:15PM

Apologies for this posting as sybperl is not directly involved but sybase
is, so maybe someone on this group has experienced my problem. 

I'm using a piped filehandle of Sybase bcp to load data from an array into a
tempdb table, like so..

   @arrayofdata = ( 0, 1, 2, 3, 4, blah blah blah .... );
   $bcpcmdline = "| bcp tempdb..tlTmp in /dev/stdin -S$SVR -U$USR -P$PWD

   open (fhBCPIN, $bcpcmdline ) || die ("Couldn't open: $bcpcmdline\n");
   print fhBCPIN join( "\n", @arrayofdata), "\n";

   close fhBCPIN;

when I run this I get the expected output, confirming everything worked OK.

   Starting copy...
   1000 rows sent to SQL Server.
   2000 rows sent to SQL Server.
   3000 rows sent to SQL Server.
   4000 rows sent to SQL Server.
   5000 rows sent to SQL Server.

   5122 rows copied.
   Clock Time (ms.): total = 1  Avg = 0 (5122000.00 rows per sec.)

but not so :-( the table is empty! so I run it through the debugger and it
works fine!  What gives?

A first point of call was playing with the 'autoflush' setting on the
filehandle and no joy, maybe I don't understand how this works properly :-(

Please note I'm using the unix bcp and it's taking input from /dev/stdin.
There is nothing wrong with this technique as the following command line
works fine.

   $ cat somefile | bcp tempdb..sometable in /dev/stdin -SSRVR -UUSER -PPWD

any help will be greatly appreciated as I kinda like it's simplicity

cheers gareth

This message is for the named person's use only. It may contain sensitive and private proprietary or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you are not the intended recipient, please immediately delete it and all copies of it from your system, destroy any hard copies of it and notify the sender. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. CREDIT SUISSE GROUP and each legal entity in the CREDIT SUISSE FIRST BOSTON or CREDIT SUISSE ASSET MANAGEMENT business units of CREDIT SUISSE FIRST BOSTON reserve the right to monitor all e-mail communications through its networks. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorized to state them to be the views of any such entity. Unless otherwise stated, any pricing information given !
in this message is indicative on
ly, is subject to change and does not constitute an offer to deal at any price quoted. Any reference to the terms of executed transactions should be treated as  preliminary only and subject to our formal written confirmation.