necesito verificar que la conexión a una base de datos Oracle desde una máquina con Windows funciona con OLE DB (no ODBC, por desgracia, mi vida sería más fácil). He conseguido conectar y sacar datos, pero no consigo que me devuelva una columna en concreto.
Using perl Syntax Highlighting
#!perl
use warnings;
use strict;
# thanks to http://sunsite.berkeley.edu/ead/tools/eaddb/fundamentals.html
# invoke the Win32::OLE methods for database connectivity
use Win32::OLE;
use Win32::OLE::Const 'Microsoft ActiveX Data Objects';
# define the conection and recordset objects
my $Conn = Win32::OLE->new("ADODB.Connection");
my $RS = Win32::OLE->new("ADODB.Recordset");
# define the data source name
my $DSN = "Provider=OraOLEDB.Oracle.1;Password=secret;Persist Security Info=True;User ID=query;Data Source=mydb";
# define the sql statement we want to execute
my $SQL = "select * from feestdag where FEES_OMSCHRIJVING like 'Tweede Kerstdag'";
# expected return (change next year)
my $result = "2011-12-26 00:00:00" ;
# open the db connection
$Conn->Open($DSN);
# open the recordset
$RS->Open($SQL, $Conn);
# loop through results until no more results are available
until ($RS->EOF) {
my $value1 = $RS->Fields("FEES_OMSCHRIJVING")->value;
my $value2 = $RS->Fields("FEES_DATUM")->value;
print "$value1\n";
print "$value2\n";
$RS->MoveNext;
}
# close recordset and connection objects
$RS->Close;
$Conn->Close;
use warnings;
use strict;
# thanks to http://sunsite.berkeley.edu/ead/tools/eaddb/fundamentals.html
# invoke the Win32::OLE methods for database connectivity
use Win32::OLE;
use Win32::OLE::Const 'Microsoft ActiveX Data Objects';
# define the conection and recordset objects
my $Conn = Win32::OLE->new("ADODB.Connection");
my $RS = Win32::OLE->new("ADODB.Recordset");
# define the data source name
my $DSN = "Provider=OraOLEDB.Oracle.1;Password=secret;Persist Security Info=True;User ID=query;Data Source=mydb";
# define the sql statement we want to execute
my $SQL = "select * from feestdag where FEES_OMSCHRIJVING like 'Tweede Kerstdag'";
# expected return (change next year)
my $result = "2011-12-26 00:00:00" ;
# open the db connection
$Conn->Open($DSN);
# open the recordset
$RS->Open($SQL, $Conn);
# loop through results until no more results are available
until ($RS->EOF) {
my $value1 = $RS->Fields("FEES_OMSCHRIJVING")->value;
my $value2 = $RS->Fields("FEES_DATUM")->value;
print "$value1\n";
print "$value2\n";
$RS->MoveNext;
}
# close recordset and connection objects
$RS->Close;
$Conn->Close;
Coloreado en 0.003 segundos, usando GeSHi 1.0.8.4
Si ejecuto el programa, tengo esto:
Using bash Syntax Highlighting
c:\drv>c:\Perl\bin\perl.exe testoledb.pl
Tweede Kerstdag
Win32::OLE::Variant=SCALAR(0x346d8bc)
Tweede Kerstdag
Win32::OLE::Variant=SCALAR(0x346d8bc)
Coloreado en 0.003 segundos, usando GeSHi 1.0.8.4
¿Por qué me sale esa referencia en el segundo valor $value2? ¿Cómo puedo desreferenciarlo?