Re: HTML -> Oracle Procedure question

From: Ron Clark <ron.clark_at_home.com>
Date: Fri, 19 Nov 1999 06:24:17 GMT
Message-ID: <3834F788.DE9BF85D_at_home.com>


jason wrote:

> Anyone know how to use the HTML <FORM> to post
> data to an Oracle procedure?
>
> I'm running Oracle Web Server V 3.0 against Oracle 8i.
>
> I've got the PL/SQL agent cartridge up and running and can quite
> happily create a webs page using Oracle procedures.
> But I want to take it a step further and capture data from, say, a
> drop down list and post this data back into another procedure.
>
> How can I do it?
>
> Below is an example of the type of procedure I'm trying to run.
>
> I call it using http://someaddress:8080/owa_dba/plsql/choose
>
> I want it to send the results of a drop-down list selection to another
> procedure called showemps.
>
> ----------
>
> create or replace procedure choose
> as
>
> begin
>
> htp.htmlOpen;
> htp.headOpen;
> htp.title('Employee Index - Make a choice');
> htp.headClose;
>
> htp.bodyOpen( cattributes => 'BGCOLOR="#000000" TEXT="#FFFFFF"');
>
> -- What should go here???
> htp.formOpen( curl => OWA_UTIL.GET_OWA_SERVICE_PATH||'showemps' );
>
> htp.formSelectOpen( cname => 'choose_dept',
> cprompt => 'Please choose an ID : ' );
>
> FOR empid_rec IN (select employee_id from employee_table)
> LOOP
>
> -- Or do I need something in here???
> htp.formSelectOption( cvalue => empid_rec.employee_id,
> cattributes =>
> 'VALUE='||OWA_UTIL.GET_OWA_SERVICE_PATH||
> 'showemps?id='||empid_rec.employee_id);
>
> END LOOP;
>
> htp.formSelectClose;
>
> htp.formSubmit('Send','Submit Search');
>
> htp.formClose;
>
> htp.bodyClose;
> htp.htmlClose;
>
> end;
> /
>
> Thanks for your help!

Jason,

You could simply use the htp.print to output the <form > tag. NOTE: the form action needs to be the name of the recieving procedure and the names of your form input variable must match the variable names of your procedure.

Example:
1) you have a database procedure like this

      create or replace procedure echoinput (pname varchar2, ptitle varchar2) is

      begin
             htp.print('<html><head><title>Your
results</title></head><body>');
             htp.print('The name passed in was '||pname);
             htp.print('The title passed in was '||ptitle);
              htp.print('</body></html>');
      end;
       /
2) the code snipplet from your html page could look like this
           <form method="POST" action="echoinput">
            <br>Name:<input type="text" name="pname" size="30"
maxlength="30">
             <br>Title:<select name="ptitle">
                                 <option value="President">Presidenta
                                 <option value="Worker">Slave
                               </select>

3)  NOTES:
     a) the form action matches your procedure name (I am assuming the
result will use the same agent )
     b) the name of the form fields match the names of the procedures
variables (order in the html page is not important)
     c) using the form method of POST will suppress the query string in
the url address line of the browser while GET will display it.
      4) you can test the procedure by calling it directly in the url
address
              ie)

http://somehost:8080/plsql/echoinput?pname=Myname&ptitle=President

Hope this helps

Ron Clark
Draedon Consulting Corp.
Ron.clark_at_home.com Received on Fri Nov 19 1999 - 07:24:17 CET

Original text of this message