Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I'm trying to retrieve some string value from a clickhouse database. My script is:
use DBI qw':sql_types'; use utf8; use open ':encoding(utf8)', ':std'; use Encode; my $dbh = DBI->connect( 'dbi:ODBC:clickhouse' ); if ($DBI::errstr) { die <<ERR; Could not connect to database $DBI::errstr ERR } $dbh->{PrintError} = 1; $dbh->{RaiseError} = 1; # long truncated DBI attribute LongTruncOk not set and/or LongReadLen +too small # for fetching milion of rows $dbh->{LongReadLen} = 255 * 255; $dbh->{LongTruncOk} = 1; $dbh->{pg_enable_utf8} = 1; $dbh->{odbc_utf8_on} = 1; # prepare SQL statement # my $sth = $dbh->prepare("$_[0]") my $sth = $dbh->prepare("select CAST('STARTEND' AS String) as COLA, 'S +TARTEND' PEPSI") or die "prepare statement failed: $dbh->errstr()"; $sth->execute() or die "execution failed: ".$dbh->errstr(); # get column list definition #my @cols = @{$sth->{NAME}}; my @row; print "Fields: $sth->{NUM_OF_FIELDS}\n"; print "Params: $sth->{NUM_OF_PARAMS}\n\n"; print join("\t\t", @{$sth->{NAME}}), "\n\n"; while($row = $sth->fetchrow_arrayref) { print join("\t\t", @$row), "\n"; } $sth = undef;
When I execute it return two columns but the values of them are "STA". If the return string is wider then it always truncating last few characters. I don't know what is happening here. Is that an ODBC driver issue?

In reply to dbi odbc return string getting truncated by perlnewbiedewbie

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-03-29 00:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found