Manual Pages for UNIX Darwin command on man DBI::DBD::Metadata
MyWebUniversity

Manual Pages for UNIX Darwin command on man DBI::DBD::Metadata

DBI::DBD::Metadata(3) User Contributed Perl DocumentationDBI::DBD::Metadata(3)

NAME

DBI::DBD::Metadata - Generate the code and data for some DBI metadata

methods

SYNOPSIS

The idea is to extract metadata information from a good quality ODBC driver and use it to generate code and data to use in your own DBI driver for the same database. For generating code to support the getinfo method:

perl -MDBI::DBD::Metadata -e "writegetinfopm('dbi:ODBC:dsn-name','user','pass','Driver')"

perl -MDBI::DBD::Metadata -e writegetinfopm dbi:ODBC:foodb username password Driver

For generating code to support the typeinfo method:

perl -MDBI::DBD::Metadata -e "writetypeinfopm('dbi:ODBC:dsn-name','user','pass','Driver')"

perl -MDBI::DBD::Metadata -e writetypeinfopm dbi:ODBC:dsn-name user pass Driver

Where "dbi:ODBC:dsn-name" is the connection to use to extract the data,

and "Driver" is the name of the driver you want the code generated for (the driver name gets embedded into the output in many places). GGeenneerraattiinngg aa GGeettIInnffoo ppaacckkaaggee ffoorr aa ddrriivveerr

The "writegetinfopm" in the DBI::DBD::Metadata module generates a

DBD::Driver::GetInfo package on standard output. This method generates a DBD::Driver::GetInfo package from the data source you specified in the parameter list or in the environment variable DBIDSN. DBD::Driver::GetInfo should help a DBD author implementing the DBI getinfo() method. Because you are just creating this package, it's very unlikely that DBD::Driver already provides a good implementation for getinfo(). Thus you will probably connect via DBD::ODBC.

Once you are sure that it is producing semi-sane data, you would

typically redirect the standard output to lib/DBD/Driver/GetInfo.pm, and then hand edit the result. Do not forget to update your Makefile.PL and MANIFEST to include this as an extra PM file that should be installed. If you connect via DBD::ODBC, you should use version 0.38 or greater; Please take a critical look at the data returned! ODBC drivers vary dramatically in their quality. The generator assumes that most values are static and places these

values directly in the %info hash. A few examples show the use of CODE

references and the implementation via subroutines. It is very likely that you have to write additional subroutines for values depending on the session state or server version, e.g. SQLDBMSVER. A possible implementation of DBD::Driver::db::getinfo() may look like: sub getinfo {

my($dbh, $infotype) = @;

require DBD::Driver::GetInfo;

my $v = $DBD::Driver::GetInfo::info{int($infotype)};

$v = $v->($dbh) if ref $v eq 'CODE';

return $v;

} Please replace Driver (or "") with the name of your driver. Note that this stub function is generated for you by writegetinfopm function, but you must manually transfer the code to Driver.pm. GGeenneerraattiinngg aa TTyyppeeIInnffoo ppaacckkaaggee ffoorr aa ddrriivveerr

The "writetypeinfopm" function in the DBI::DBD::Metadata module

generates on standard output the data needed for a driver's typeinfoall method. It also provides default implementations of the typeinfoall method for inclusion in the driver's main implementation file. The driver parameter is the name of the driver for which the methods will be generated; for the sake of examples, this will be "Driver". Typically, the dsn parameter will be of the form "dbi:ODBC:odbcdsn", where the odbcdsn is a DSN for one of the driver's databases. The user and pass parameters are the other optional connection parameters that will be provided to the DBI connect method.

Once you are sure that it is producing semi-sane data, you would

typically redirect the standard output to lib/DBD/Driver/TypeInfo.pm, and then hand edit the result if necessary. Do not forget to update your Makefile.PL and MANIFEST to include this as an extra PM file that should be installed. Please take a critical look at the data returned! ODBC drivers vary dramatically in their quality. The generator assumes that all the values are static and places these

values directly in the %info hash.

A possible implementation of DBD::Driver::typeinfoall() may look like: sub typeinfoall {

my ($dbh) = @;

require DBD::Driver::TypeInfo;

return [ @$DBD::Driver::TypeInfo::typeinfoall ];

} Please replace Driver (or "") with the name of your driver. Note that this stub function is generated for you by the writetypeinfopm function, but you must manually transfer the code to Driver.pm. AUTHORS Jonathan Leffler (previously ), Jochen Wiedmann , Steffen

Goeldner , and Tim Bunce .

perl v5.8.8 2006-02-07 DBI::DBD::Metadata(3)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™