Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DBI
- DBD::Oracle
- cx_Oracle
- sub dbConn($$$) {
- # Set Oracle enviroment path information
- $ENV{"LD_LIBRARY_PATH"} = "/usr/lib/oracle/11.2/client64/lib";
- $ENV{"NLS_LANG"} = "ENGLISH_CANADA.AL32UTF8";
- $ENV{"ORACLE_HOME"} = "/usr/lib/oracle/11.2/client64";
- $ENV{"PATH"} = "/usr/lib/oracle/11.2/client64/bin:".$ENV{"PATH"};
- # Get parameters passed to subroutine
- my $db_pass = shift();
- my $db_database = shift();
- my $SID = shift();
- # Connect to db
- my $odbh = DBI->connect("DBI:Oracle:$SID",
- $db_database,
- $db_pass,
- {
- RaiseError => 1,
- PrintError => 1,
- AutoCommit => 0
- }
- ) || die("FATAL ERROR:Unable to connect to the Database: $DBI::errstr");
- # Return our database handle
- return ($odbh);
- sub dbDisco($) {
- # Get parameter passed to subroutine
- my $odbh = shift();
- # Disconnect from DB
- $odbh->disconnect;
- }
- sub loadDevices {
- # Connect to database
- my $odbh = dbConn( "password", "username", "ENGPRD" );
- # Get device list
- my @devices = dbGetDevices( $odbh );
- # Disconnect from FDB
- dbDisco($odbh);
- return ( @devices );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement