_ TWF  _ Code Chap 29

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
HOME | BACK | NEXT | MENU | SEARCH | ORDER | COMMENT | HELPINFO -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

29code01.pl


#!/usr/local/bin/perl

#

# /www/cgi-bin/ora_search.pl

#

#   A CGI test for accessing an Oracle DB

#   Author: Mike Erwin

#   e-mail: mikee@outer.net

#   Version: 1.0  -  6/23/95

#   Revision History:-- Very Simple-- Proof of Concept only.

#

####################################################################

require "/www/cgi-bin/formlib.pl";



#  Various Startup Variables and whatnots

####################################################################



$|              = 1;              

$datestr        = `date '+%m/%d/%y %H:%M:%S'`;   #

$timedate       = `date '+%H%M%S'`;

chop ($datestr);

chop ($timedate);



&GetFormArgs();        # parse arguments passed from FORM (now in %in)

$ENV{PATH_INFO} ne '' && &GetPathArgs($ENV{PATH_INFO});



$sSITE_NO                      =$in{sSITE_NO};

$sWEB_MGR                      =$in{sWEB_MGR};

$sDATE_UPD                     =$in{sDATE_UPD};

$sSITE_NAME                    =$in{sSITE_NAME};

$sIP_ADDR                      =$in{sIP_ADDR};



if ($sSITE_NO || $sWEB_MGR || $sDATE_UPD || $sSITE_NAME || $sIP_ADDR) {

	$use_site = 1;

}

$mWEB_MGR                      =$in{mWEB_MGR};

$mMANAGER                      =$in{mMANAGER};

$mHIRE_DATE                    =$in{mHIRE_DATE};

$mE_MAIL                       =$in{mE_MAIL};



if ($mWEB_MGR || $mMANAGER || $mHIRE_DATE || $mE_MAIL) {

	$use_mgr = 1;

}

$TMP_FILE                      ="/tmp/query.sql";

$SQL_APP                       ="/usr/oracle/bin/sqldba";



print STDOUT "Content-Type: text/html\n\n\n";



open(QUERY,"> $TMP_FILE");

print QUERY "connect scott/tiger;\n";

if ($use_site) {

    print QUERY "select * from SITE where ";

    if ($sSITE_NO) {

         print QUERY "SITE_NO='$sSITE_NO'";

    }

    if ($sWEB_MGR) {

         print QUERY "WEB_MGR='$sWEB_MGR'";

          }

    if ($sDATE_UPD) {

         print QUERY "DATE_UPD=$sDATE_UPD";

    }

    if ($sSITE_NAME) {

         print QUERY "SITE_NAME=$sSITE_NAME";

    }

    if ($sIP_ADDR) {

         print QUERY "IP_ADDR=$sIP_ADDR";

    }

}

if ($use_mgr) {

print QUERY "select * from WEB_MANAGER where ";

    if ($mWEB_MGR) {

         print QUERY "WEB_MGR='$mWEB_MGR'";

    }

    if ($mMANAGER) {

         print QUERY "MANAGER='$mMANAGER'";

    }

    if ($mHIRE_DATE) {

         print QUERY "HIRE_DATE=$sDATE_UPD";

    }

    if ($mE_MAIL) {

         print QUERY "E_MAIL=$mE_MAIL";

    }

}



print QUERY ";\n";

close (QUERY);



print STDOUT "<h2>Query Result</h2><pre>";



$ENV{'PATH'} .= ":/usr/oracle/bin";

$ENV{'ORACLE_SID'} = "SAMP";

$ENV{'ORACLE_HOME'} = "/usr/oracle";



open (ORACLE,"$SQL_APP < $TMP_FILE |");

while(<ORACLE>) {

         print STDOUT "$_";

}

close (ORACLE);

print STDOUT "</pre>";

29code02.htm


<HTML>

<HEAD>

<TITLE>Oracle Test DB Engine</TITLE>

</HEAD><BODY>

<h1>Test Web Database</h1><HR>

<FORM METHOD="POST" ACTION="http://sneech.austin.apple.com/cgi-bin/ora_search.pl">

<H3>SITE Table</H3>

Site Number:		<INPUT TYPE="text" NAME="sSITE_NO" SIZE=10><BR>

Site Manager:		<INPUT TYPE="text" NAME="sWEB_MGR" SIZE=20><BR>

Date of Last Update:	<INPUT TYPE="text" NAME="sDATE_UPD" SIZE=20><BR>

Site Name:		<INPUT TYPE="text" NAME="sSITE_NAME" SIZE=40><BR>

Site Address:		<INPUT TYPE="text" NAME="sIP_ADDR" SIZE=16><P>

<H3>WEB_MANAGER Table</H3>

Site Manager:           <INPUT TYPE="text" NAME="mWEB_MGR" SIZE=20><BR>

Personnel Manager:      <INPUT TYPE="text" NAME="mMANAGER" SIZE=20><BR>

Hire Date:              <INPUT TYPE="text" NAME="mHIRE_DATE" SIZE=20><BR>

E-Mail Address:         <INPUT TYPE="text" NAME="mE_MAIL" SIZE=40><P>

<INPUT TYPE="submit" NAME="Search" VALUE="Search">

</BODY>

</HTML>




-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
HOME | BACK | NEXT | MENU | SEARCH | ORDER | COMMENT | HELPINFO -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

E-Mail: The Web Foundations at twf@lanw.com
URL: http://www.lanw.com/twf/codech29.htm
Text - Copyright © 1995, Ed Tittel, Mark Gaither, Sebastian Hassinger, & Mike Erwin.
Web Layout - Copyright © 1995, LANWrights & IMPACT Online.
Revised -- February 15th, 1996 [James Michael Stewart - WebMaster - IMPACT Online]

HTML 2.0 Checked!