Thomas A. Lowery wrote:
>
> > Tom, what's your opinion? Can we use the FieldAttributeEnum's or
> > should we add %DBCOLUMNFLAGS to DBD::ADO?
>
> My opinion is to use FieldAttritueEnum. Two reasons: It's supported
> in TypeLib, and inherit to ADO. Less problems with changes in the
> future.
>
O.k.! The use of the FieldAttritueEnum flags in column_info() may
look like:
sub column_info {
...
while ( ! $RecSet->{EOF} ) {
...
my @Fields;
my $AdoType = $RecSet->Fields('DATA_TYPE' )->{Value};
my $ColFlags = $RecSet->Fields('COLUMN_FLAGS')->{Value};
my $IsLong = ( $ColFlags & $ado_consts->{adFldLong } ) ? 1 : 0;
my $IsFixed = ( $ColFlags & $ado_consts->{adFldFixed} ) ? 1 : 0;
my $SqlType = DBD::ADO::db::convert_ado_to_odbc( $dbh, $AdoType, $IsLong,
$IsFixed );
...
$Fields[ 4] = $SqlType; # DATA_TYPE
...
In order to handle $IsLong and $IsFixed, convert_ado_to_odbc() needs
a small extension:
sub convert_ado_to_odbc {
my ($dbh, $AdoType, $IsLong, $IsFixed ) = @_;
return $dbh->DBI::set_err( -1,
"convert_ado_to_odbc: call without any attributes.")
unless $AdoType;
unless( $ado_types_supported ) {
&_determine_type_support($dbh);
}
if ( exists $myado_types_supported2->{$AdoType}{$IsLong}{$IsFixed} ) {
return $myado_types_supported2->{$AdoType}{$IsLong}{$IsFixed};
}
if ( exists $myado_types_supported->{$AdoType} ) {
return $myado_types_supported->{$AdoType};
}
return $AdoType;
}
where $myado_types_supported2 may look like:
$myado_types_supported2 = {
# AdoType IsLong IsFixed => SqlType
$ado_consts->{adBinary } => { 0 => { 0 => SQL_VARBINARY
, 1 => SQL_BINARY }
, 1 => { 0 => SQL_LONGVARBINARY
, 1 => SQL_UNKNOWN_TYPE }}
, $ado_consts->{adChar } => { 0 => { 0 => DBI::SQL_VARCHAR
, 1 => DBI::SQL_CHAR }
, 1 => { 0 => SQL_LONGVARCHAR
, 1 => SQL_UNKNOWN_TYPE }}
, $ado_consts->{adWChar } => { 0 => { 0 => SQL_WVARCHAR
, 1 => SQL_WCHAR }
, 1 => { 0 => SQL_WLONGVARCHAR
, 1 => SQL_UNKNOWN_TYPE }}
# , $ado_consts->{adVarBinary} =>
# , $ado_consts->{adVarChar } =>
# , $ado_consts->{adVarWChar } =>
};
Excuse the code snippets - there are still many open issues ...
For your demo table in mytest.mdb, the following DATA_TYPE's
are returned:
ID : 4
num1 : 4
num2 : 5
num3 : 6
num4 : 8
num5 : -11
num6 : 2
txt1 : -9
txt2 : -9
memo1: -10
dt1 : 9
cur1 : 2
cur2 : 2
cur3 : 2
cur4 : 2
cur5 : 2
cur6 : 2
cur7 : 2
an2 : -11
yn1 : 16
yn2 : 16
yn3 : 16
oo1 : -4
hl1 : -10
Steffen