Re: Perl Database Select Results Being Truncated
by injunjoel (Priest) on Apr 28, 2005 at 16:02 UTC
|
| [reply] |
|
|
I'll talk to our database team. I originally wanted a blob type, but they said that they would give me a varchar 1000 to fit my need, but that raises a good point if Perl somehow truncates based on the 255 typical limitation of varchar. The thing that confuses me though is that if 255 is the varchar limit, why the sybase dbase allows it, and allows for me to do a command like select and retrieve the entire entry?
Thanks again for any continued assistance.
| [reply] |
|
|
Hi again-
I've tried the LongReadLen, and it still truncates. The database team has said that they kept the type varchar to save space in the database, and that it is possible to go over the 255 character contstraint for the varcar, so I am at a loss why the truncation still happens. Here is a clip of the new code with the LongReadLen attribute set:
$dbh->{LongReadLen} = 65536;
$statement = 'SELECT Description FROM DevelopmentTool WHERE ShortName like "%PSP%"';
$sth = $dbh->prepare($statement);
$sth->execute;
while (($Description) = $sth->fetchrow) {
print $Description . "\n\n";
}
Talk soon.
| [reply] |
Re: Perl Database Select Results Being Truncated
by mpeppler (Vicar) on Apr 28, 2005 at 15:44 UTC
|
Which database is this, and what perl module/client are you using?
Michael
| [reply] |
|
|
I am using a Sybase database, and the Perl DBI module.
I even tried to write a simple, non-CGI version of the script, where the perl code only does the select on the trouble column, and print to the command line...same results.
| [reply] |
|
|
Ah.
Then please make sure that you have Sybase 12.5 Client Libraries installed, and that your DBD::Sybase module is recent (1.04 or later), and that it was built with the 12.5 libraries.
Otherwise the client side of the connection tells the server side that it doesn't know about "wide" varchar columns, and you get the 255 char truncation.
Michael
| [reply] |
Re: Perl Database Select Results Being Truncated
by TedPride (Priest) on Apr 28, 2005 at 17:24 UTC
|
Another, much more likely possibility is that the information is being cropped on input rather than output. Have you checked your database file, either by looking at the file itself or through an admin utility, to make sure there's more than 255 characters of data?
And yes, Sybase varchar is usually 255 characters max. | [reply] |
|
|
| [reply] |
|
|
That did it...thank you so much for the help. I was pointing to older versions of the perl executable, and once I updated to versino 5.8.3, it worked the first time.
Thanks again for the help.
Chris
| [reply] |
|
|
Hi there-
Actually, that was the first thing I did. Within the database file, I can query and retrieve the entire entry without truncation, so I know the file is valid.
Thanks again for all of the help...
| [reply] |
|
|
Greetings again,
I read through the source of DBD::Sybase and came upon this little snippet
# Calling sp_datatype_info returns the appropriate data for the server
+ that
# we are currently connected to.
# In general the data is static, so it's not really necessary, but ASE
+ 12.5
# introduces some changes, in particular char/varchar max lenghts that
+ depend
# on the server's page size. 12.5.1 introduces the DATE and TIME datat
+ypes.
might be worth investigating? If not, I think mpeppler is the author of this module, perhaps you can /msg him about this.
-InjunJoel
"I do not feel obliged to believe that the same God who endowed us with sense, reason and intellect has intended us to forego their use." -Galileo
| [reply] [d/l] |