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: "Mark Sutfin" <MSutfin at affinitygroup dot com>
Subject: RE: Unable to format sproc output
Date: Apr 28 2004 3:04PM

 On Wednesday, April 28, 2004 7:53 AM, Michael Pepplar wrote:

> -----Original Message-----
> From: 
> [] On Behalf Of Michael Peppler
> Sent: Wednesday, April 28, 2004 7:53 AM
> To: Sybperl-L Mailing List
> Subject: Re: Unable to format sproc output
> 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.

This is becoming clearer... I'm going to give the $sth->{PRECISION} a
go.. But I'm wondering why the explicit conversion (of data in a
NULLable column) to CHAR and right padding with spaces doesn't work..
Can you shed any light on this?

Column:	fname
Datatype	char(10) (null)
Data:		'robert'
Example: 	select convert(char(10), fname) + space(4)