Thanks Thomas exactly what I was after
Dan -----Original Message----- From: Thomas A. Lowery [mailto:[EMAIL PROTECTED]] Sent: Thursday, November 29, 2001 7:08 PM To: [EMAIL PROTECTED] Subject: Re: examples of type_info Hello Dan, Look at the tests for DBD::ADO and DBD::ODBC. The type_info is used to convert a standard SQL type to a source specific. An example would be a SQL_VARCHAR. When you type_info(SQL_VARCHAR) you get the "best" possible data type match for that source/database. Included is an example of type_info(SQL_VARCHAR) results from a number of different databases and DBI drivers. Tom perl -w type_info.pl set DBI_DSN=dbi:ADO:File Name=.\access.udl DBI::VERSION 1.20 DBD::ADO::VERSION 2.4_01 MSDASQL.1 2.7 SQL_VARCHAR type: VARCHAR set DBI_DSN=dbi:ADO:Provider=Microsoft.Jet.OLEDB.4.0; Data Source=.\mytest.mdb DBI::VERSION 1.20 DBD::ADO::VERSION 2.4_01 Microsoft.Jet.OLEDB.4.0 2.7 SQL_VARCHAR type: VarChar set DBI_DSN=dbi:ADO:File Name=.\mssql.udl DBI::VERSION 1.20 DBD::ADO::VERSION 2.4_01 SQLOLEDB.1 2.7 SQL_VARCHAR type: varchar set DBI_DSN=dbi:ADO:Provider=MSDASQL;Driver={Microsoft Text Driver (*.txt; *.csv)};DBQ=.\;ConnectionTimeout=30 DBI::VERSION 1.20 DBD::ADO::VERSION 2.4_01 MSDASQL.1 2.7 SQL_VARCHAR type: CHAR set DBI_DSN=dbi:ADO:Provider=MSDASQL;Driver={Microsoft Excel Driver (*.xls)}; DBQ=.\AddressDB.xls;ConnectionTimeout=30 DBI::VERSION 1.20 DBD::ADO::VERSION 2.4_01 MSDASQL.1 2.7 SQL_VARCHAR type: VARCHAR set DBI_DSN=dbi:ADO:File Name=.\oracle8i.udl DBI::VERSION 1.20 DBD::ADO::VERSION 2.4_01 OraOLEDB.Oracle.1 2.7 SQL_VARCHAR type: VARCHAR2 set DBI_DSN=dbi:ODBC:PERL_TEST_ACCESS perl -w type_info.pl DBI::VERSION 1.20 SQL_VARCHAR type: VARCHAR set DBI_DSN=dbi:ODBC:PERL_TEST_MSSQL DBI::VERSION 1.20 SQL_VARCHAR type: varchar set DBI_DSN=dbi:ODBC:PERL_TEST_ORACLE DBI::VERSION 1.20 SQL_VARCHAR type: VARCHAR2 #!perl # vim:ts=4:sw=4:ai:aw: use strict; use DBI qw(:sql_types); # Simple connect and select script using DSN-Less ADO connection. my $dsn = $ENV{DBI_DSN} || q{dbi:ADO:Provider=Microsoft.Jet.OLEDB.4.0; Data Source=.\mytest.mdb}; # User and Password not needed. my $user = $ENV{DBI_USER} || undef; my $pass = $ENV{DBI_PASS} || undef; # Connect to the database. my $dbh = DBI->connect( $dsn, $user, $pass, {PrintError=>1,RaiseError=>1} ) or die $DBI::errstr; print "DBI::VERSION $DBI::VERSION\n"; print "DBD::ADO::VERSION $DBD::ADO::VERSION\n"; # Information about the ADO/OLEDB Provider my $ado_conn = $dbh->{ado_conn}; print $ado_conn->{Provider}, "\t",$ado_conn->{Version}, "\n"; my $tia = $dbh->type_info(SQL_VARCHAR); print "SQL_VARCHAR type: ", $tia->{TYPE_NAME}, "\n"; $dbh->disconnect if $dbh; exit; __END__ On Thu, Nov 29, 2001 at 05:59:11PM +1300, Dan Horne wrote: > > I know the definitions, syntax are in the doco, but can someone send me some > concrete examples of type_info being used? -- Thomas A. Lowery See DBI/FAQ http://tlowery.hypermart.net _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
