On Mon, Jun 10, 2002 at 02:51:34PM -0400, Pradeep Padala wrote:
> > I'm not sure what you mean by "hasn't defined SQL_DBMS_VER".
> >
> > The DBI spec says "doesn't provide a name to number mapping for the
> > information type codes or the results. Applications are expected
> > to use the integer values directly".
>
> > Handle what?
>
> Handling hardcoding like
>
> sub get_info {
> my $infotype = shift;
>
> if($infotype == 18) {
> return $somecolumn;
> }
> }
>
> or something like
>
> sub get_info {
> my %infotypes = {
> "SQL_DBMS_VER" => 18,
> ..
> };
> my $infotype = shift;
>
> if($infotype == $infotypes{"SQL_DMS_VER"}) {
> return $somecolumn;
> }
> }
>
> I am trying to figure out a good way to do this in the sybase DBD. I guess
> the second approach is better.
I'd stronly advise against using symbolic names inside the driver
(other than in comments). There's just no need. Only wastes time and space.
Read perldoc DBI::DBD and you'll find this example:
sub get_info {
my($dbh, $info_type) = @_;
require DBD::<foo>::GetInfo;
my $v = $DBD::<foo>::GetInfo::info{int($info_type)};
$v = $v->($dbh) if ref $v eq 'CODE';
return $v;
}
That, together with minor tweaking of what
perl -MDBI::DBD -e write_getinfo_pm dbi:ODBC:foo_db username password >
DBD/<foo>/GetInfo.pm
will generate for you, should be just fine.
Tim.