perlnewbiedewbie has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to retrieve some string value from a clickhouse database. My script is:
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?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;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: dbi odbc return string getting truncated
by talexb (Chancellor) on Aug 07, 2019 at 13:24 UTC | |
by soonix (Canon) on Aug 07, 2019 at 14:07 UTC | |
by afoken (Chancellor) on Aug 07, 2019 at 18:42 UTC | |
by perlnewbiedewbie (Initiate) on Aug 08, 2019 at 12:33 UTC | |
by hippo (Bishop) on Aug 08, 2019 at 12:51 UTC | |
by talexb (Chancellor) on Aug 08, 2019 at 14:41 UTC | |
by perlnewbiedewbie (Initiate) on Aug 09, 2019 at 10:16 UTC | |
by erix (Prior) on Aug 09, 2019 at 10:51 UTC | |
Re: dbi odbc return string getting truncated
by jcb (Parson) on Aug 09, 2019 at 23:38 UTC |
Back to
Seekers of Perl Wisdom