Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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:

Hi,

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?

Comment on Perl DBI SQL Server not returning full column
Download Code
Re: Perl DBI SQL Server not returning full column
by Random_Walk (Parson) on Aug 19, 2013 at 19:44 UTC

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

    Cheers,
    R.

    Pereant, qui ante nos nostra dixerunt!
Re: Perl DBI SQL Server not returning full column
by poj (Priest) 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";
    poj
Re: Perl DBI SQL Server not returning full column
by kcott (Abbot) 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

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.

    -derby

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1050072]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2014-11-28 13:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (197 votes), past polls