Re: Oracle via WWW
Date: 23 Sep 1994 14:23:29 -0500
Message-ID: <35v9vh$9qu_at_dalsn02d.dalsn02d>
In article <CwL6F7.vw_at_info.uucp>, Daryl Erwin <derwin_at_mach2.wlu.ca> wrote:
>
>Mike,
> Care to share any examples? Can we take a peek at what you've done?
>--
>Daryl Erwin Net Address: derwin_at_mach2.WLU.CA
Yeah, here's a real quickie that shows basic queries in an oraperl cgi script. (note, I've cut and pasted this from a larger application so I haven't tested this exact code. Hopefully I haven't missed anything major...)
The html form:
<title>Oraperl Test</title>
<FORM action="http://your.domain.name/cgi-bin/oraperltest.pl" METHOD=POST> <H1>Oraperl Test Application</H1>
Your Member Id: <INPUT NAME="member" TYPE=text SIZE="20" VALUE=""> <p> <INPUT TYPE=submit VALUE="Check Membership">
</FORM>
The oraperltest.pl app:
#!/usr/local/bin/oraperl
# # This application gets a "member id" from a text field in a form. #
# Set up the ORACLE variables to log in
$ENV{'ORACLE_SID'} = 'your-database-goes-here'; $ENV{'ORACLE_HOME'} = '/home/dba/oracle/product/7.0.16';
print STDOUT "Content-type: text/html\n\n"; print STDOUT "<TITLE> Catalog Type Selection </TITLE>\n"; print STDOUT "<H1> Catalog Type Selection </H1>\n";
# Log in to the ORACLE database and connect
$lda = &ora_login('your-database','your-userid','your-passwd') ||
print STDOUT "broken login: $ora_errstr\n";
$con_len = $ENV{'CONTENT_LENGTH'}; $rem_host = $ENV{'REMOTE_HOST'}; $rem_add = $ENV{'REMOTE_ADDR'}; #
# Get the variable from the STDIN input stream #
sysread(STDIN,$search_str,$con_len);
_at_formdata = split(/([&=])/, $search_str);
$i=0;
foreach $elem (_at_formdata)
{
$i++;
if ($elem eq 'member') {$member = _at_formdata[$i+1]};
}
$selstring = "SELECT FIRSTNAME FROM PEOPLE WHERE PERSON_ID = "; $selstring = $selstring.$member; $csr = &ora_open($lda, $selstring); if (($memname) = &ora_fetch($csr)) { print STDOUT "Welcome <B>$memname</B>!"; }
do ora_close($csr);
I hope this helps. There are a couple of perl and C examples that come with the ncsa httpd server. I found these extremely useful guides.
Mike Marolda - mmarolda_at_onramp.net Received on Fri Sep 23 1994 - 21:23:29 CEST