Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ vi test.pl
- "test.pl" 41 lines, 992 characters
- #usr/bin/perl -w
- use DBI;
- use strict;
- use warnings;
- #Variables
- my $username='PCGLOBES_BATCH_USER';
- my $password='pbu4wao03!';
- my $database='WAO03';
- my $server='tht048a3.dadc.sbc.com';
- # Remove end of line from input
- #chomp $str;
- # Get the rows from database
- my $dbh = DBI->connect("DBI:oracle:$database;host=$server",$username,$password)
- || die "Could not connect to database: $DBI::errstr";
- my $sth = $dbh->prepare('select * from WAO_NECA_VH1')
- || die "$DBI::errstr";
- $sth->execute();
- # Print number of rows found
- if ($sth->rows < 0) {
- print "Sorry, no records found.\n";
- } else {
- printf ">> Found %d domains\n", $sth->rows;
- # Loop if results found
- while (my $results = $sth->fetchrow_hashref) {
- my $domainname = $results->{name}; # get the domain name field
- my $url = $results->{url}; # get the URL field
- printf " +--- \e[1;42m %s (%s)\e[0m\n", $domainname, $url;
- }
- }
- # Disconnect
- $sth->finish;
- $dbh->disconnect;
- "test.pl" 41 lines, 984 characters
- $ perl test.pl
Add Comment
Please, Sign In to add comment