#! /usr/oracle/bin/oraperl

# creating an HTML form

print ("Content-type: TEXT/HTML\n\n");
print ("<HTML><TITLE>VNS Database Managment Form</TITLE><BODY>\n");
print ("<h2>VNS Database Managment Form </h2><hr>\n");

print ("<b>List of all clips:<BR>\n");


################ GET ##################
print ("<FORM ACTION=\"http://kayak.npac.syr.edu:1963/cgi-bin/vser/admpv2\"
METHOD=\"GET\">\n");

######## SQL stuff ###########

$ENV{'ORACLE_HOME'}='/usr/oracle';
$ENV{'ORACLE_SID'}='nodb';

$lda = &ora_login('','michal','michal');

# first find out how many server there are.


$cur = &ora_open($lda, " select distinct server from clip ");

$nfields = &ora_fetch($cur);

while (@servers = &ora_fetch($cur) )
{

    $query = " select title , clipid from clip where server = '@servers' ";
#    print ("$query\n");
    $csr = &ora_open($lda, $query);
    
    print ("<br><b>SERVER : @servers </b><BR> \n");
    print ("<SELECT NAME=\"clipid\" SIZE=\"10\">\n");
    $nf = &ora_fetch($csr);
#    print ("ROWS SELECTED = $nf ");
    while ( ($title, $clipid) = (&ora_fetch($csr, 1)) )
    {
    
      print ("<OPTION VALUE=$clipid> $title\n");

    }


    print ("</SELECT><br>\n");
    print ("<INPUT TYPE=\"submit\" value=\"Details\">");
    print ("<INPUT TYPE=\"reset\" value=\"Reset\">");

}
#print ("<INPUT TYPE=\"submit\" value=\"Details\">");
#print ("<INPUT TYPE=\"reset\" value=\"Reset\">");
print ("</FORM>\n");

&ora_close($cur);
&ora_close($csr);

&ora_logoff($lda);

print ("</BODY></HTML>\n");

