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: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: Unable to format sproc output
Date: Apr 28 2004 1:53PM

On Tue, 2004-04-27 at 18:26, Mark Sutfin wrote:
> If there's a better list for this question, please point me in the
> right direction..!
> $ perl -MDBI -le 'print $DBI::VERSION' = 1.42
> $ perl -MDBD::Sybase -le 'print $DBD::Sybase::VERSION' = 1.02
> $ perl -v This is perl, v5.8.2 built for PA-RISC2.0
> Sybase 11.9.2
> HPUX 11i
> I have a stored procedure called from a .pl script. The final
> statement in the sproc is a SELECT from a temporary table, the result
> set from which is stored in a flat file. 
> In the origin table, all columns except col1 are NULLABLE, there are
> no indexes and all columns are CHAR(nn) datatypes.

A NULLABLE char() column will be treated the same way as a varchar()
column, i.e. trailing whitespace will be truncated.

isql will display the formating correctly because it post-processes the
data for display, fetching the max column width and doing something like
a printf("%${width}s", $coldata). 

If you need to output the data in fixed width format then you need to
get this data as well, and do the post-processing in the same way.

IIRC you can use $sth->{PRECISION} to get the length of columns.

Michael Peppler                              Data Migrations, Inc.             
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short
or long term contract positions -