Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. DBI
  2. DBD::Oracle
  3.  
  4. cx_Oracle
  5.  
  6. sub dbConn($$$) {
  7. # Set Oracle enviroment path information
  8. $ENV{"LD_LIBRARY_PATH"} = "/usr/lib/oracle/11.2/client64/lib";
  9. $ENV{"NLS_LANG"} = "ENGLISH_CANADA.AL32UTF8";
  10. $ENV{"ORACLE_HOME"} = "/usr/lib/oracle/11.2/client64";
  11. $ENV{"PATH"} = "/usr/lib/oracle/11.2/client64/bin:".$ENV{"PATH"};
  12.  
  13. # Get parameters passed to subroutine
  14. my $db_pass = shift();
  15. my $db_database = shift();
  16. my $SID = shift();
  17.  
  18. # Connect to db
  19. my $odbh = DBI->connect("DBI:Oracle:$SID",
  20. $db_database,
  21. $db_pass,
  22. {
  23. RaiseError => 1,
  24. PrintError => 1,
  25. AutoCommit => 0
  26. }
  27. ) || die("FATAL ERROR:Unable to connect to the Database: $DBI::errstr");
  28.  
  29. # Return our database handle
  30. return ($odbh);
  31.  
  32.  
  33.  
  34. sub dbDisco($) {
  35.  
  36. # Get parameter passed to subroutine
  37. my $odbh = shift();
  38.  
  39. # Disconnect from DB
  40. $odbh->disconnect;
  41. }
  42.  
  43.  
  44.  
  45. sub loadDevices {
  46.  
  47. # Connect to database
  48. my $odbh = dbConn( "password", "username", "ENGPRD" );
  49.  
  50. # Get device list
  51. my @devices = dbGetDevices( $odbh );
  52.  
  53. # Disconnect from FDB
  54. dbDisco($odbh);
  55.  
  56. return ( @devices );
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement