#!/usr/local/bin/perl

use Oraperl;
$ENV{"ORACLE_HOME"} = "/opt/oracle/product/8.1.5";

$sUsername = "cs290w\@csdb";
$sPassword = "cs290w";

$hConnection = &ora_login( "", $sUsername, $sPassword );

$hQuery = 
&ora_open($hConnection, 
"SELECT * FROM cs290adm.big_ten");

print "SELECT * FROM cs290adm.big_ten \n";
&fDisplay;

$hQuery = 
&ora_open($hConnection, 
"SELECT * FROM cs290adm.big_ten WHERE state = 'IN'");

print "SELECT * FROM cs290adm.big_ten WHERE state = 'IN' \n";
&fDisplay;

$hQuery = 
&ora_open($hConnection, 
"SELECT * FROM cs290adm.big_ten WHERE enrolled > 30000");

print "SELECT * FROM cs290adm.big_ten WHERE enrolled > 30000 \n";
&fDisplay;

$hQuery = 
&ora_open($hConnection, 
"SELECT * FROM cs290adm.big_ten WHERE enrolled > 30000 AND
founded < 1855");

print "SELECT * FROM cs290adm.big_ten WHERE enrolled > 30000 AND founded < 1855 
\n";
&fDisplay;

$hQuery = 
&ora_open($hConnection, 
"SELECT * FROM cs290adm.big_ten WHERE colors LIKE '%Gold%'");

print "SELECT * FROM cs290adm.big_ten WHERE colors LIKE '%Gold%' \n";
&fDisplay;

&ora_close($hQuery); 
&ora_logoff($hConnection);

sub fDisplay
{
 @amValues = &ora_fetch($hQuery);
 while (@amValues != 0)
  {
  $sName=$amValues[0];
  $sCity=$amValues[1];
  $sState=$amValues[2];
  $iEnrolled=$amValues[3];
  $iFounded=$amValues[4];
  $sNickname=$amValues[5];
  $sColors=$amValues[6];
  $iJoined=$amValues[7];
  print "$sName $sCity $sState $iEnrolled $iFounded \n";
  print "$sNickname $sColors $iJoined \n\n";
  @amValues = &ora_fetch($hQuery);
  }
 print "***************************************** \n";
}
