Guest User

Untitled

a guest
Jan 11th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. $ vi test.pl
  2. "test.pl" 41 lines, 992 characters
  3. #usr/bin/perl -w
  4. use DBI;
  5. use strict;
  6. use warnings;
  7. #Variables
  8. my $username='PCGLOBES_BATCH_USER';
  9. my $password='pbu4wao03!';
  10. my $database='WAO03';
  11. my $server='tht048a3.dadc.sbc.com';
  12.  
  13. # Remove end of line from input
  14.  
  15. #chomp $str;
  16.  
  17. # Get the rows from database
  18.  
  19. my $dbh = DBI->connect("DBI:oracle:$database;host=$server",$username,$password)
  20. || die "Could not connect to database: $DBI::errstr";
  21. my $sth = $dbh->prepare('select * from WAO_NECA_VH1')
  22. || die "$DBI::errstr";
  23. $sth->execute();
  24.  
  25. # Print number of rows found
  26. if ($sth->rows < 0) {
  27. print "Sorry, no records found.\n";
  28. } else {
  29. printf ">> Found %d domains\n", $sth->rows;
  30. # Loop if results found
  31. while (my $results = $sth->fetchrow_hashref) {
  32. my $domainname = $results->{name}; # get the domain name field
  33. my $url = $results->{url}; # get the URL field
  34. printf " +--- \e[1;42m %s (%s)\e[0m\n", $domainname, $url;
  35. }
  36. }
  37.  
  38. # Disconnect
  39. $sth->finish;
  40. $dbh->disconnect;
  41. "test.pl" 41 lines, 984 characters
  42. $ perl test.pl
Add Comment
Please, Sign In to add comment