View Single Post
  #2 (permalink)  
Old 08-17-2007, 12:08 AM
raj raj is offline
D-Web Programmer
 
Join Date: Jul 2007
Posts: 89
raj is on a distinguished road
Smile Connecting Database using PERL

hi murali,

MySql: (its very similar to php mysql function)

//#-- Connection
$db = Mysql->connect($host, $database, $user, $password);

link for your ref:
Perl and MySQL - Connect MySQL with Perl


Oracle:

#!/opt/products/bin//perl
# This path may be different, it is platform dependent.
#

use DBI;
#---------------------------------------------------------------------------
#-- change user name, password, table name, column names
#---------------------------------------------------------------------------
$dbname = 'dbi:Oracle:desy';
$dbuser = 'scott';
$pass = 'tiger';
$table = 'emp';
$columns = 'empno,ename';
#
#---------------------------------------------------------------------------
#
# connect to the database
$dbh = DBI->connect($dbname, $dbuser, $pass) or die "Cant connect to : $DBI::errstr\n";
# select entries in the database
$sth = $dbh->prepare(qq{select $columns from $table});
# execute the select statement
$sth->execute;
while (@row = $sth->fetchrow_array)
{
print "@row\n";
}
# end the reading of results
$sth->finish;
# disconnect from the database
$dbh->disconnect;
# that's all
exit;

link for your ref:

Oracle interfaces, Perl DBI

TSG: Using Oracle from Perl
Reply With Quote