#!/usr/bin/perl $ENV{'ORACLE_HOME'} = '/prog/oracle/10.2.0'; use DBI; use Mysql; use strict; #############MYSQL############### sub sub_mysql { my $myhost = "localhost"; my $mydatabase = "db"; my $mytablename = "table"; my $myuser = "user"; my $mypwd = "password"; my $myconn = Mysql->connect($myhost, $mydatabase, $myuser, $mypwd); $myconn->selectdb($mydatabase); my $myquery = "INSERT INTO $mytablename (date, status, well) VALUES (NOW(),'$_[0]','$_[1]')"; my $myexecute = $myconn->query($myquery); } ###############END MYSQL################ ##############ORACLE SQL############## my $orahost = "oracle.bla.com"; my $oraport = "1000"; my $orasid = "I01"; my $orauser = ""; my $orapwd = ""; my $oraconn = "dbi:Oracle:HOST=$orahost;SID=$orasid;port=$oraport"; my $db = DBI->connect( $oraconn, $orauser, $orapwd ) || die( $DBI::errstr . "\n" ); my $oraquery = "SELECT date, status, well FROM bla where > sysdate -1 "; my $sth = $db->prepare($oraquery); $sth->execute(); my ($date, $well, $status); $sth->bind_columns(\$date, \$well, \$status); while( $sth->fetch() ) { sub_mysql("$status","$well"); } $db->disconnect; #############END ORACLE SQL#############