Dean Arnold wrote:
I'm finding I frequently need to convert the DBI type metadata
from a result set into a string representation (either for display purposes,
or to generate additional queries).

Is there a need/desire to add a new $sth metadata item
TYPE_STRING that would contain that info, eg,

$sth->{TYPE}->[0] == SQL_INTEGER => $sth->{TYPE_STRING}->[0] = 'INTEGER'
$sth->{TYPE}->[0] == SQL_DECIMAL, $sth->{PRECISION}->[0] == 10, $sth->{SCALE}->[0] == 2 => $sth->{TYPE_STRING}->[0] = 'DECIMAL(10,2)'


etc.

This appears to be one of those things that could have a default
implemention at the DBI layer, but overridden by the driver. This is a bit
more convenient than reconstructing things from type_info(), esp. since
precision/scale would already be supplied.

Since I've coded this translation about a dozen times
now, I could probably whip up a patch to DBI for the default.
(Probably based on type_info(), if driver provides it, else just
a best guess)

Opinions ? Have I overlooked something like this thats already in the DBI ?

DBD::Informix has always provided such an attribute:


$sth->{ix_NativeTypeName}

it does so precisely because it is more useful than the numeric values, and doubly more useful than having to decode the type qualifiers for an Informix data type.

Obviously, I use a (more or less) systematically named, driver-specific attribute so as to avoid treading on DBI's toes, but it would equally fairly obviously be easy to revise the code to respond to the standardized name.

--
Jonathan Leffler ([EMAIL PROTECTED], [EMAIL PROTECTED]) #include <disclaimer.h>
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/




Reply via email to