Re: Example of using DBD:ODBC to connect to Oracle with no DSN



OK, I figured it out. If you go to Control Panel, open up the ODBC
control screen, create a File DSN, and then look at the contents of the
file, it will show you what syntax to use. A sample file looks as:

[ODBC]
DRIVER=Oracle in OraHome92
UID=DOBO
TLO=O
PFC=10
FWC=F
CSR=F
MDI=Me
MTS=F
BAM=IfAllSuccessful
FRL=Lo
GDE=F
RST=T
LOB=T
FDL=10
FRC=10
QTO=T
FEN=T
XSM=Default
EXC=F
APA=T
DBA=W
DBQ=SG
SERVER=SG

Based on this, after getting rid of the redundant stuff, and with some
trial and error, I found that this connection string works fine:

$dbh = DBI->connect("dbi:ODBC:Driver={Oracle in OraHome92};DBQ=SG",

$conf{'user'}, $conf{'password'},
{PrintWarn => 0, AutoCommit => 0,
PrintError => 0,RaiseError => 1})
|| die "Cannot connect to Oracle database:
$DBI::errstr.\n";


So basically DBQ = server_name will do the trick for you.

Cheers,

dobomode


dobom...@xxxxxxxxx wrote:
> I wasn't sure if my question was clear: I'd like to see an example of
> connecting to Oracle using DBD::ODBC without a DSN string, i.e. with
> the "dbi:ODBC:Driver" syntax.
>
> Thanks!
>
> dobomode
>
>
>
>
> dobomode@xxxxxxxxx wrote:
> > Hello there,
> >
> > Currently I am using this to connect to Oracle via DBD::ODBC
> >
> > $dbh = DBI->connect("dbi:ODBC:sg.corp.com", $conf{'user'},
> > $conf{'password'},
> > {PrintWarn => 0, AutoCommit => 0,
> > PrintError => 0,RaiseError => 1})
> > || die "Cannot connect to Oracle database:
> $DBI::errstr.\n";
> >
> > Works fine and smoothly.
> >
> > Now, since I am developing this app for people at my company to
use,
> I
> > don't want to have everybody set up a DSN entry (sg.corp.com in
the
> > example above) in their control panel. Instead, I'd like to use the
> > dbi:ODBC:DRIVER syntax to connect to Oracle directly bypassing the
> DNS
> > entries. I've searched like crazy but could not find much on the
> topic.
> > Anybody?
> >
> > Thanks!
> >
> > P.S. If you're curious why DBD:ODBC vs DBD:Oracle, it's the fact
that
> > the latter has some issues with dealing with BLOB (I've spent a
full
> > day troubleshooting this to no success, tried quickly ODBC and
bingo
> -
> > magic!)

.



Relevant Pages

  • Re: Problem connecting to SQL Server from Access Database
    ... Have you tried creating a new ODBC Dsn from Control panel since the DB ... If everything works normal with the ODBC connection then there is ...
    (comp.databases.ms-access)
  • Re: Word 2000/2002 - Proper Mail Merge steps for ODBC?
    ... > Document to connect to a Secured Access Database, ... using the ODBC provider for OLEDB. ... they have a .dsn extension. ... directly (in the Open/Select Data Source dialog box). ...
    (microsoft.public.word.mailmerge.fields)
  • Re: Silly ODBC Connection problem
    ... it seems to me this must be done interactively on each client--either that or use the magical "DSN-less" connection. ... It's been 11 or years or so since I wrote about ODBC so it's getting kinda fuzzy. ... 556-9205 (Pacific time) ... > created a System DSN named "MyDSN" in the ODBC Administrator tool. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Beginner: How do I link via ODBC from a PC into an AS400?
    ... Options, Miscellaneous, How to keep Microsoft Office Documents Protected, ... The moment I select ODBC Databases from Files of Type, ... I have added a User DSN based on the Client Access Driver, ...
    (microsoft.public.access.externaldata)
  • Re: Word 2000/2002 - Proper Mail Merge steps for ODBC?
    ... you have to use ODBC (or the old DDE ... but then you go onto say that an "ODBC connection set up ... >> Document to connect to a Secured Access Database, ... >they have a .dsn extension. ...
    (microsoft.public.word.mailmerge.fields)