Tim Bunce wrote:
>
> On Fri, Feb 01, 2002 at 09:21:09AM +0100, Steffen Goeldner wrote:
> > A new patch for DBD::Oracle:
> >
> > - get_info() now takes a numeric value
> > - SQL_DBMS_VERSION is supported
> >
> > More info types if desired. (I don't like a blindfold
> > adoption of the Oracle ODBC driver results.)
>
> Great, many thanks.
>
> Could I ask that you move the hash setup outside the function
> and put in there only the values that are constant.
>
> Then in the function do something like
>
> sub get_info {
> my($dbh, $info_type) = @_;
> my $v = $get_info_constants{int($info_type)};
> return $v if defined $v;
> ... handle the other values ...
> }
>
> I'd like this to be a good and efficient model for other drivers
> to follow.
>
> Umm, here's another idea... for the non-constant items put them into
> the %get_info_constants hash as anonymous subs that return the appropriate
> value. Then in get_info do:
>
> sub get_info {
> my($dbh, $info_type) = @_;
> my $v = $get_info_constants{int($info_type)};
> $v = &$v($dbh) if ref $v eq 'CODE';
> return $v;
> }
>
> Umm, carrying on from there... move %get_info_constants into DBD::Oracle::GetInfo
> and make get_info do:
>
> sub get_info {
> my($dbh, $info_type) = @_;
> require DBD::Oracle::GetInfo;
> my $v = $DBD::Oracle::GetInfo::info{int($info_type)};
> $v = &$v($dbh, $info_type) if ref $v eq 'CODE';
> return $v;
> }
Two Umm's more and nothing remains to be done :-)
Steffen