anjaana78 has asked for the wisdom of the Perl Monks concerning the following question:

I have a qestion about bcp using sybperl. I know we can bcp data from a table to a text file. but I have a query which is gonna return me 100 results. i wanna get that result into a text file. Can i bcp the result from query to text file . or is there any other appropriate way to do it.

Replies are listed 'Best First'.
Re: question about bcp
by turumkhan (Novice) on May 16, 2001 at 22:39 UTC
    one way is to use:
    $allrows = $handle->fetchall_arrayref(); my($i, $j); for $i ( 0 .. $#{$allrows} ) { for $j ( 0 .. $#{$allrows->[$i]} ) { print $allrows->[$i][$j]; } print FILE "\n"; }
Re: question about bcp
by busunsl (Vicar) on May 17, 2001 at 10:52 UTC
    You can't use bcp to put the result of a query into a file, bcp works with tables only.
    For more information on Sybperl go to Michael Peppler's site. He is the author of Sybperl and DBD::Sybase.
    The Sybperl man-page is here

    To put the result of a query in a file use the way turumkhan suggested (though his snippet needs a bit of modification ;-).