note
VSarkiss
<p>OK, now we're getting somewhere. <c>:-)</c></p>
<p>So the underlying database is Sybase, and you used to use [cpan://Sybase::CTLib] to handle some <c>VARBINARY</c>-ish type. If so, and if you have the option, the easiest choice may be to switch to [cpan://DBD::Sybase] instead of [cpan://DBD::ODBC]. Then a lot of the behavior should be as you expect. (The last time I used Sybase was about five years ago, so things may have changed.)</p>
<p>I think I understand your problem: you know how to format the columns as string or hex, you just don't know which ones should be formatted in each way. If that's the case, then you may want to look at the <c>TYPE</c> attribute of the statement handle (documented in [doc://DBI], usually used along with the <c>type_info</c> method), which will allow you to find the underlying type of each result column.
It sounds like that may give you enough information to decide how to format each column. Something like this (cheesy, untested) example:<code>
my $type_i_want = $dbh->type_info( [ SQL_whatever ] );
#
# ...later...
#
$sth->execute(@parameters);
my @types = $sth->{TYPE};
my $row = $sth->fetch();
for (my $i = 0; $i < $sth->{NUM_OF_FIELDS}; $i++)
{
if ($types[$i] eq $type_i_want)
{
printf "0x%x", $row[$i];
}
else
{
printf "%s", $row[$i];
}
}
</code>
</p>
<p>Hope that gets you closer.</p>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-72267">
<p><small><i>[id://149675|Do not rebuke them with harsh words ... but rather lead them gently - with URLs - so that they may learn wisdom.]</i></small></p>
</div></div>
581926
581949