Ganesh,

Try updating your value for $dsn this way:

- Instead of using this:

> 
> $dsn = 'dbi:Oracle:$database:in-gh01:1521';
>

- Try using this:

  $dsn = "dbi:Oracle:host=in-gh01:sid=$database";


Please make note of the use of double-quotes ("") instead of
single-quotes ('') in my example.  It will ensure the variable
containing the name of the database/SID gets expanded when the
statement is evaluated, instead of being interpreted as a literal.

Good luck!

Marcus


 

> -----Original Message-----
> From: Ganesh Bendre [mailto:ganesh.b.ben...@gmail.com] 
> Sent: Thursday, June 02, 2011 9:48 AM
> To: dbi-users@perl.org
> Subject: Need Help with DBI for oracle
> 
> Hi,
> 
> I am using the following code for fetching some data.
> but not able to connect
> 
> *CODE:*
> #!C:/Perl/bin/perl.exe
> 
> use DBI;
> use DBD::Oracle;
> 
> print "Content-type: text/html \n\n";
> 
> $platform = "ORACLE";
> $database = "I8Q.GRP.COM";
> $tablename = "COUNTY_ADD";
> $user = "dba";
> $pw = "dbapass";
> 
> $dsn = 'dbi:Oracle:$database:in-gh01:1521';
> 
> $connect = DBI->connect($dsn, $user, $pw);
> 
> $query = "select ctycode,ctydesc from county_add"; 
> $query_handle = $connect->prepare($query);
> 
> $query_handle->execute();
> 
> $query_handle->bind_columns(undef, \$ctycode, \$ctydesc);
> 
> while($query_handle->fetch()) {
>    print "$ctycode, $ctydesc <br />";
> }
> *CODE END*
> **
> **
> I am getting the following error when i try to run the above code
> **
> *Error:*
> DBI connect('$database:in-gh01:1521','dba',...) failed: 
> ORA-06401: NETCMN:
> id driver designator (DBD ERROR: OCIServerAttach) at 
> exequery2.pl line 21 Can't call method "prepare" on an 
> undefined value at exequery2.pl line 25.
> *Error END*
> 
> *I have installed *
> *DBD::Oracle*
> *DBI*
> **
> **
> *i am stuck with this for almost one week Please help me out*
> **
> *Ganesh.*
> **
> 

Reply via email to