RE: Perl DBI and DBD::ODBC for Oracle on Windows



Hello

1) By adding sid=xxxx in the DSN, you should be able to point to the correct SID.
So in your case :
my $DSN = 'driver={Microsoft ODBC for Oracle};server=10.1.6.9:1521;sid=XXXXXX;uid=oradbuser;pwd=oradbpassword;';

2) You should not use "Microsoft ODBC for Oracle" that is a very old driver, that perhaps works for Oracle 7 or 8.
If you already installed Oracle InstantClient SQLPLUS package, then I would recommend you to download the components : Basic and ODBC and extract them in the same folder as sqlplus.
Then follow instructions in README files and specially in "ODBC_IC_Readme_Win.html" file so that you should be able to use the driver provide by ODBC instantclient package. It should be something like "Oracle in instantclient_xx_y"

Best Regards
Pascal



-----Message d'origine-----
De : Ming Yu [mailto:my600080@xxxxxxxxx]
Envoyé : mardi 28 juillet 2009 14:14
À : dbi-users@xxxxxxxx
Objet : Perl DBI and DBD::ODBC for Oracle on Windows

Hi,

I've been trying to connect to a remote Oracle database through Windows
XP but couldn't make it work after a few days' effort. This is what
I've done:

1. Install ActivePerl on Windows.
2. Install DBI module.
3. Install DBD::ODBC module.
4. Inside my perl code, I choose to connect without DSN:

use DBI;
use DBD::ODBC;

my $database = "ORADB";

my $DSN = 'driver={Microsoft ODBC for
Oracle};server=10.1.6.9:1521;uid=oradbuser;pwd=oradbpassword;';

my $dbh = DBI->connect("dbi:ODBC:$DSN") or die "$DBI::errstr\n";

My first question: in the $DSN string, where can I put the database
name? I found this syntax from the internet but it didn't say anything
about the database name location.

My second question: after I run the script, here is the error I got:

DBI connect('driver={Microsoft ODBC for
Oracle};server=10.1.6.9:1521;uid=oradbuser;pwd=oradbpassword;','',....)
failed: [Microsoft][ODBC driver for Oracle][Oracle]
ORA-12514: TNS:listener does not currently know of service requested in
connect descriptor (SQL-NA000) [state was NA000 now 01000]
[Microsoft][ODBC Driver Manager] The driver doesn't support the version
of ODBC behavior that the application requested (see SQLSetEnvAttr).
(SQL-01000) at testOracle.pl line 31

The database connection works ok because I can connect to the datasbase
using SQLPLUS that comes with Instance Client for Microsoft Windows 32.

Thanks a lot!

Ming






.



Relevant Pages

  • Re: Beginner: How do I link via ODBC from a PC into an AS400?
    ... The ODBC Data source administrator has tabs: User DSN, System DNS, ... Install the IBM ODBC driver for the AS400 on every PC that needs to connect. ... passthrough queries as inputs will not be efficient. ...
    (microsoft.public.access.externaldata)
  • RE: Connection error SQLSetConnectAttr failed
    ... I don't think I've ever seen machine and database names be numeric values. ... DSN when you created it. ... | I have an undocumented ODBC driver..Or the supplier at least won't give ... and would prefer to do it via windows service. ...
    (microsoft.public.data.odbc)
  • RE: Run-time error 3011 using Foxpro ODBC
    ... it is enough to just mention the DSN. ... -The constant acTable is ignored unless the database source type is MS ... Dim strConnect As String ... DoCmd.TransferDatabase acImport, "ODBC Database", strConnect,, ...
    (microsoft.public.data.odbc)
  • Inno User Input Form and ODBC DSN
    ... I have a third party application that we currently install to hundreds of ... It is an ODBC System DSN. ... we manually create the ODBC and select the default database ... DSNs and the client will choose the DSN that related to his database. ...
    (microsoft.public.vb.database)
  • Re: Linking to back end on a web server ?
    ... When I do the File--Get External Data and select the DSN, ... "You cannot use ODBC to import from, export to, or link an external ... Microsoft Jet or ISAM database table to your database. ... that DSN-based connection to a DSN-less connection. ...
    (microsoft.public.access.externaldata)