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 <{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, 'STARTEND' 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;