Tim Bunce wrote:
> 
> On Thu, Feb 21, 2002 at 12:14:31PM +0100, Steffen Goeldner wrote:

> > Should type_info_all() depend on ora_server_version(),
> > DBD::Oracle::ORA_OCI() or both?
> 
> Both I think, since you need both to be >=8 to be able to use the
> types in typical situations.

O.k. (see attached patch).

> And if you want to go the 'whole hog' you could add in Oracle 9's new
> types (says he with a hopeful grin :-)

If I had an Oracle 9 server and client :-(
But if somebody posts the output of MS ODBC Test, or
somebody uses DBD::ODBC and this patch:

  <http:[EMAIL PROTECTED]/msg00951.html>

and this script:

  #!perl

  $\ = "\n";
  $, = "\t";

  use DBI();

  my $dbh = DBI->connect('dbi:ODBC:ora9','','',{ odbc_version => 3 }) or die 
$DBI::errstr;
     $dbh->{ RaiseError } = 1;
     $dbh->{ PrintError } = 1;

  my $tia = $dbh->type_info_all;
  my $h = shift @$tia;
  for my $f ( sort { $h->{$a} <=> $h->{$b} } keys %$h )
  {
    $f =~ tr/_/ /;
    printf lc( $f ) . "\t";
  }
  print '';
  for my $t ( @$tia )
  {
    print @$t;
  }

....


Steffen
*** DBD-Oracle-1.12a/Oracle.pm  Sat Feb 16 20:00:39 2002
--- Oracle.pm   Sat Feb 23 21:00:00 2002
***************
*** 658,677 ****
            SQL_DATETIME_SUB    =>16,
            NUM_PREC_RADIX      =>17,
        };
-       # Based on the values from Oracle 8.0.4 ODBC driver
-       my $varchar2_maxlen = (DBD::Oracle::ORA_OCI()>=8) ? 4000 : 2000;
        my $ti = [
          $names,
            [ 'LONG RAW', -4, '2147483647', '\'', '\'', undef, 1, '0', '0',
              undef, '0', undef, undef, undef, undef, -4, undef, undef
            ],
!           [ 'RAW', -3, 255, '\'', '\'', 'max length', 1, '0', 3,
              undef, '0', undef, undef, undef, undef, -3, undef, undef
            ],
            [ 'LONG', -1, '2147483647', '\'', '\'', undef, 1, 1, '0',
              undef, '0', undef, undef, undef, undef, -1, undef, undef
            ],
!           [ 'CHAR', 1, 255, '\'', '\'', 'max length', 1, 1, 3,
              undef, '0', '0', undef, undef, undef, 1, undef, undef
            ],
            [ 'NUMBER', 3, 38, undef, undef, 'precision,scale', 1, '0', 3,
--- 658,675 ----
            SQL_DATETIME_SUB    =>16,
            NUM_PREC_RADIX      =>17,
        };
        my $ti = [
          $names,
            [ 'LONG RAW', -4, '2147483647', '\'', '\'', undef, 1, '0', '0',
              undef, '0', undef, undef, undef, undef, -4, undef, undef
            ],
!           [ 'RAW', -3, 2000, '\'', '\'', 'max length', 1, '0', 3,
              undef, '0', undef, undef, undef, undef, -3, undef, undef
            ],
            [ 'LONG', -1, '2147483647', '\'', '\'', undef, 1, 1, '0',
              undef, '0', undef, undef, undef, undef, -1, undef, undef
            ],
!           [ 'CHAR', 1, 2000, '\'', '\'', 'max length', 1, 1, 3,
              undef, '0', '0', undef, undef, undef, 1, undef, undef
            ],
            [ 'NUMBER', 3, 38, undef, undef, 'precision,scale', 1, '0', 3,
***************
*** 679,691 ****
            ],
            [ 'DOUBLE', 8, 15, undef, undef, undef, 1, '0', 3,
              '0', '0', '0', undef, undef, undef, 8, undef, 10
            ],
!           [ 'DATE', 9, 19, '\'', '\'', undef, 1, '0', 3,
!             undef, '0', '0', undef, '0', '0', 11, undef, undef
            ],
!           [ 'VARCHAR2', 12, $varchar2_maxlen, '\'', '\'', 'max length', 1, 1, 3,
!             undef, '0', '0', undef, undef, undef, 12, undef, undef
!           ]
          ];
        return $ti;
      }
--- 677,707 ----
            ],
            [ 'DOUBLE', 8, 15, undef, undef, undef, 1, '0', 3,
              '0', '0', '0', undef, undef, undef, 8, undef, 10
+           ]
+         ];
+       my $version = ( ora_server_version($dbh)->[0] < DBD::Oracle::ORA_OCI() )
+                   ?   ora_server_version($dbh)->[0] : DBD::Oracle::ORA_OCI();
+       if ( $version < 8 ) {
+           push @$ti,
+           [ 'VARCHAR2', 12, 2000, '\'', '\'', 'max length', 1, 1, 3,
+             undef, '0', '0', undef, undef, undef, 12, undef, undef
+           ];
+       }
+       else {
+           push @$ti,
+           [ 'VARCHAR2', 12, 4000, '\'', '\'', 'max length', 1, 1, 3,
+             undef, '0', '0', undef, undef, undef, 12, undef, undef
            ],
!           [ 'BLOB', 30, 2147483647, '\'', '\'', undef, 1, 1, 0,
!             undef, 0, undef, undef, undef, undef, 30, undef, undef
            ],
!           [ 'CLOB', 40, 2147483647, '\'', '\'', undef, 1, 1, 0,
!             undef, 0, undef, undef, undef, undef, 40, undef, undef
!           ];
!       }
!       push @$ti,
!       [ 'DATE', 93, 19, '\'', '\'', undef, 1, 0, 3,
!         undef, 0, 0, undef, 0, 0, 9, 3, undef
        ];
        return $ti;
      }

Reply via email to