Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Web forms via PL/SQL

Re: Web forms via PL/SQL

From: Torben Holm <torben.holm_at_miracleas.dk>
Date: Wed, 25 Sep 2002 16:28:23 -0800
Message-ID: <F001.004D977F.20020925162823@fatcity.com>


Hi Ron,

In short (as I am hitting the bed)
What I have here is done via 9ias.
It (ias) requiers that you define a document table with some specifick column (you can add your own ) (look in the documentation) The script I am sending you requiers some other scripts and access diffrent kind of tables, but I hope it can give you a hint. If you need some more details I'll be back tomorrow reards
Torben

Navn                                      NULL?    Type
----------------------------------------- -------- 
----------------------------
ID                                                 NUMBER
NAME                                      NOT NULL VARCHAR2(128)
MIME_TYPE                                          VARCHAR2(128)
DOC_SIZE                                           NUMBER
DAD_CHARSET                                        VARCHAR2(128)
LAST_UPDATED                                       DATE
CONTENT_TYPE                                       VARCHAR2(128)
CONTENT                                            LONG RAW
BLOB_CONTENT                                       BLOB
STATUS                                             VARCHAR2(45)
OWNER                                              VARCHAR2(30)
CUSTOMERID                                         NUMBER
DOC_NAME                                           VARCHAR2(128)
SHORT_DESCRIPTION                                  VARCHAR2(4000)
EMPID                                              NUMBER
DATO                                               DATE

create or replace package MaintainVisitReports is

   procedure main;
   procedure show(p_customerid number := null);    procedure upload(p_customerid number := null, p_short_description in varchar2 := null, p_initials in varchar2 := null, file in varchar2 := null);

   procedure download(p_name varchar2);
   procedure deletefile(p_customerid number := null, p_id number);    procedure filelist ;
end ;
/
create or replace package body MaintainVisitReports is Procedure main is
begin

   ccs.ccs;
   htp.p('<TABLE>');
   htp.p('<TR>');
   htp.p('<TD>');
   htp.p('<a href="mirres.MaintainVisitReports.show" 
TARGET="main">Upload</a>');
   htp.p('</TD>');
   htp.p('<TD>');
   htp.p('<a href="mirres.MaintainVisitReports.filelist" 
TARGET="main">List</a>');
   htp.p('</TD>');
   htp.p('</TR>');
   htp.p('</TABLE>');
   htp.p('<HR>');

end main;
-- 
-----------------------------------------------------------------------------
--
-- 
-----------------------------------------------------------------------------
procedure show(p_customerid number := null)
is
   l_custname varchar2(50);
   cursor GetCustomer is
   select custname from customer where customerid = p_customerid;
   begin

open GetCustomer;
fetch Getcustomer into l_custname;
close GetCustomer;

ccs.ccs;
Javascript.script;
javascript.call_popup;
Javascript.end_script;
--
htp.p('<html>');
htp.p('<body>');
--
htp.p('<FORM  enctype="multipart/form-data" 
action="mirres.MaintainVisitReports.upload" method="POST">');
if p_customerid is not null then
   htp.p('<INPUT TYPE="SUBMIT" VALUE="Luk"   style="border-style: solid; 
border-width: 1" onClick="window.close()">');
end if;
htp.p('<TABLE background="" border=0  cellPadding=0 cellSpacing=0 
style="CURSOR: auto; WIDTH: 100%" width="100%">');
htp.p('<TR>');
htp.p('<TD class="label" 
WIDTH="120px">'||misc.get_translation('Kunde')||'</TD>');
htp.p('<TD>');
htp.p('<INPUT TYPE="TEXT" VALUE="'||l_custname||'" onfocus = "blur()" 
SIZE="50" MAXLENGTH="50">');
if p_customerid is null then
   htp.p('&nbsp;<A HREF="javascript:call_popup(1)"><IMG 
SRC="/images/list.gif" alt="LIST" border="0" align=bottom ></A>&nbsp;<a 
href="javascript:clearcustomer()"><IMG SRC="/images/viper.gif" 
alt="vipe" border="0" align=bottom></A></TD>');
else
   htp.p('<TD>');
end if;
--
htp.p('<INPUT TYPE="HIDDEN" NAME="p_customerid" 
VALUE="'||p_customerid||'" SIZE="0" MAXLENGTH="32"></TD>');
htp.p('</TR>');
--
htp.p('<TR rowspan="100%">');
htp.p('<TD class="label" 
WIDTH="70px">'||misc.get_translation('Initialer')||'</TD>');
htp.p('<TD >');
   components.initials;
htp.p('</TD>');
htp.p('</TR>');
--
htp.p('<TR>');
htp.p('<TD class="label">Beskrivelse:</TD>');
htp.p('<TD>');
htp.p('<TEXTAREA name="p_short_description" style="HEIGHT: 87px; WIDTH: 
283px" maxlength="512"></TEXTAREA>');
htp.p('</TD>');
htp.p('</TR>');
--
htp.p('<TR>');
htp.p('<TD class="label" WIDTH="120px">'||misc.get_translation('Fil der 
skal uploades')||'</TD>');
htp.p('<TD><INPUT type="file" name="file" style="border-style: solid; 
border-width: 1" ></TD>');
htp.p('</TR>');
--
htp.p('<TR>');
htp.p('<TD>&nbsp;</TD>');
htp.p('<TD><INPUT type="submit" value="Upload file"   
style="border-style: solid; border-width: 1" ></TD>');
htp.p('</TR>');
--
htp.p('</TABLE');
htp.p('</FORM>');
if p_customerid is not null then
   htp.p('<HR>');
   htp.p('<p>Files</p>');
   htp.p('<TABLE background="" border=1  cellPadding=0 cellSpacing=0 
style="CURSOR: auto; WIDTH: 100%" width="100%">');
   if p_customerid is null then
      htp.p('<TH ALIGN=left>Kunde</TH>');
   end if;
   htp.p('<TH ALIGN=left>Filnavn</TH>');
   htp.p('<TH ALIGN=left>Beskrivelse</TH>');
   htp.p('<TH ALIGN=left>Opdateret</TH>');
   htp.p('<TH ALIGN=left>Initialer</TH>');
   htp.p('<TH ALIGN=left>Slet</TH>');
   for i in (select v.id, v.name, v.CUSTOMERID, v.DOC_NAME, 
v.SHORT_DESCRIPTION, v.DOC_SIZE, v.LAST_UPDATED, e.EMP_INITIALS, v.empid
             from Visit_Reports v, emp e where
             v.customerid = p_customerid
             and v.empid = e.emp_id(+)) loop
       htp.p('<TR>');
       if p_customerid is null then
          htp.p('<TD class="tabeldata" nowrap>'||i.CUSTOMERID||'</TD>');
       end if;
       htp.p('<TD class="tabeldata" nowrap><a 
href="mirres.MaintainVisitReports.download?p_name='||i.name||'">'||i.DOC_NAME||'('||to_char(i.DOC_SIZE/1024,'99999999d0')||' 
K)</A></TD>');
       htp.p('<TD 
class="tabeldata">'||nvl(i.SHORT_DESCRIPTION,'&nbsp')||'</TD>');
       htp.p('<TD class="tabeldata" 
nowrap>'||to_char(i.LAST_UPDATED,'DD-MM-YYYY HH24:MI:SS')||'</TD>');
       htp.p('<TD class="tabeldata" 
nowrap>'||nvl(i.EMP_initials,'&nbsp;')||'</TD>');
       htp.p('<TD class="tabeldata" nowrap><a 
href="mirres.MaintainVisitReports.deletefile?p_customerid='||to_char(p_customerid)||'&p_id='||to_char(i.id)||'" 
onclick="return confirm('||''''||misc.get_translation('Er du sikker på 
at du vil slette valgte dokument!')||''''||')" >'||'Ja'||'</A></TD>');
       htp.p('</TR>');
   end loop;
end if;
htp.p('</TABLE>');
htp.p('</body>');
htp.p('</html>');
end show;
-- 
-----------------------------------------------------------------------------
--
-- 
-----------------------------------------------------------------------------
procedure upload(p_customerid number := null, p_short_description in 
varchar2 := null, p_initials varchar2 := null, file varchar2 := null)
is
begin
    update visit_reports set
        short_description = p_short_description,
       customerid = p_customerid,
      empid = p_initials,
    doc_name = substr(file,instr(file,'/')+1),
    owner = user
        where name = file;
    insert into journal (customerid, text,contactid, journal_event_id)
    values(p_customerid, p_short_description|| '<a 
href="mirres.MaintainVisitReports.download?p_name='||file||'" 
target="_blank">Se</a>', null, -2); /* -2 = Besøgsrapport/visitreport */
    commit;
    MaintainVisitReports.show(p_customerid=>p_customerid);
end upload;
-- 
-----------------------------------------------------------------------------
--
-- 
-----------------------------------------------------------------------------
procedure filelist is
begin
   ccs.ccs;
   htp.p('<html>');
   htp.p('<body>');
   htp.p('<p>Filer</p>');
   htp.p('<TABLE background="" border=1  cellPadding=0 cellSpacing=0 
style="CURSOR: auto; WIDTH: 100%" width="100%">');
   htp.p('<TH ALIGN=left>Kunde</TH>');
   htp.p('<TH ALIGN=left>Filnavn</TH>');
   htp.p('<TH ALIGN=left>Beskrivelse</TH>');
   htp.p('<TH ALIGN=left>Opdateret</TH>');
   htp.p('<TH ALIGN=left>Initialer</TH>');
   htp.p('<TH ALIGN=left>Slet</TH>');
   for i in (select v.id, v.name, c.CUSTNAME, v.DOC_NAME, 
v.SHORT_DESCRIPTION,
             v.DOC_SIZE, v.LAST_UPDATED, e.EMP_INITIALS, v.empid
             from Visit_Reports v, emp e, customer c where
             v.empid = e.emp_id(+) and
             v.customerid = c.customerid) loop
       htp.p('<TR>');
       htp.p('<TD class="tabeldata" nowrap>'||i.CUSTNAME||'</TD>');
       htp.p('<TD class="tabeldata" nowrap><a 
href="mirres.MaintainVisitReports.download?p_name='||i.name||'">'||i.DOC_NAME||'('||to_char(i.DOC_SIZE/1024,'99999999d0')||' 
K)</A></TD>');
       htp.p('<TD 
class="tabeldata">'||nvl(i.SHORT_DESCRIPTION,'&nbsp;')||'</TD>');
       htp.p('<TD class="tabeldata" 
nowrap>'||to_char(i.LAST_UPDATED,'DD-MM-YYYY HH24:MI:SS')||'</TD>');
       htp.p('<TD class="tabeldata" 
nowrap>'||nvl(i.EMP_initials,'&nbsp;')||'</TD>');
       htp.p('<TD class="tabeldata" nowrap><a 
href="mirres.MaintainVisitReports.deletefile?p_customerid=&p_id='||to_char(i.id)||'" 
onclick="return confirm('||''''||misc.get_translation('Er du sikker på 
at du vil slette valgte dokument!')||''''||')">'||'Ja'||'</A></TD>');
       htp.p('</TR>');
   end loop;
   htp.p('</TABLE>');
   htp.p('</body>');
   htp.p('</html>');

end filelist;
-- 
-----------------------------------------------------------------------------
--
-- 
-----------------------------------------------------------------------------
procedure deletefile(p_customerid number := null, p_id number) is
begin
   delete from visit_reports where id = p_id;
   commit;
   if p_customerid is null then
     mirres.MaintainVisitReports.filelist;
   else
     mirres.MaintainVisitReports.show(p_customerid=>p_customerid);
   end if;
end deletefile;
-- 
-----------------------------------------------------------------------------
--
-- 
-----------------------------------------------------------------------------
procedure download(p_name varchar2) is
   l_document blob;
   l_mime_type varchar2(128);
begin
   select blob_content, mime_type into l_document, l_mime_type from 
visit_reports
   where name = p_name;
   owa_util.mime_header(l_mime_type, FALSE);
   htp.p('Content-Length: ' || dbms_lob.getlength(l_document));
   owa_util.http_header_close;
   wpg_docload.download_file(l_document);
end download;
end;
/


Ron Thomas wrote:


>I need to write a pl/sql procedure to produce a form via the pl-sql cartridge. Not a problem- been
>doing this kinda thing now for a couple of years.
>
>Now I need to handle a <INPUT TYPE=FILE> tag in the form. Anyone know how to process the result via
>pl/sql or am I going to need to write a cgi script to handle it.
>
>Ron Thomas
>Hypercom, Inc
>rthomas_at_hypercom.com
>Each new user of a new system uncovers a new class of bugs. -- Kernighan
>
>
>
-- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Torben Holm INET: torben.holm_at_miracleas.dk Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Received on Wed Sep 25 2002 - 19:28:23 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US