Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Perl DBI SQL Server not returning full column

by ruv (Initiate)
on Aug 19, 2013 at 19:19 UTC ( #1050072=perlquestion: print w/replies, xml ) Need Help??
ruv has asked for the wisdom of the Perl Monks concerning the following question:


I am having an issue with SQL server and perl. If I run my sql statement via isql I get back what I am expecting. But when running from perl all columns after the first seem to be truncated. I have the below set.

$dbh->{LongTruncOk} = 1; $dbh->{LongReadLen} = 1000 * 1024; Expected output: | xxxxx | 2013-08-19 10:04:53.843 | nnnn | description what I am getting: | xxxxx | 2013-08-19 10:0 | n | desci
Any idea's?

Replies are listed 'Best First'.
Re: Perl DBI SQL Server not returning full column
by Random_Walk (Prior) on Aug 19, 2013 at 19:44 UTC

    Perhaps if you set $dbh->{LongTruncOk} = 0; it will throw a useful error


    Pereant, qui ante nos nostra dixerunt!
Re: Perl DBI SQL Server not returning full column
by poj (Monsignor) on Aug 19, 2013 at 20:00 UTC
    Any idea's?

    See if this test script displays the same problem ;

    #!perl use strict; use DBI; my $dbh = ..; # your connect credentials # temp test table setup my $t = '#test'; $dbh->do("CREATE TABLE $t (COL1 VARCHAR(100))"); $dbh->do("INSERT INTO $t VALUES (?)",undef,'A'x60); my ($s) = $dbh->selectrow_array("SELECT * FROM $t"); print '| ',('1234567890'x6)," |\n"; print "| $s |\n";
Re: Perl DBI SQL Server not returning full column
by derby (Abbot) on Aug 20, 2013 at 11:41 UTC

    It would be nice to see the connection code, the sql and the exec. From your code snippet, not only is the data being truncated but it's also misspelling -- that's one of two things: a typo in your writeup or you're not really connecting to the database you want.


    update:And the DDL that defines the truncated fields as well.

Re: Perl DBI SQL Server not returning full column
by kcott (Chancellor) on Aug 20, 2013 at 09:23 UTC

    G'day ruv,

    Welcome to the monastery.

    Your assumption that the data you're receiving has been truncated may be incorrect. Can you use Data::Dumper (or equivalent) to determine exactly the data you receive. If this shows truncation, post the code you're using to get the data; otherwise, post the code outputting your resultset.

    Provide us with sufficient information so we can help you: at the moment, all we have is what you want and what you get; we know nothing about the data you received, what you did to get it, how you received it, how you formatted it or how you output it. If in doubt, refer to the guidelines in "How do I post a question effectively?".

    -- Ken

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1050072]
Front-paged by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2018-06-25 00:34 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.