Discussion on:

Message 1 of 3
0 Votes
+ -
Processing HTML in PL/SQL with a WAF
Soon after I first started writing web applications using Oracle PL/SQL packages I realised that I was continually rewriting the same code over and over, so, I and a couple of my co-workers wrote what we called our WAF (Web Application Framework) package (inspired by a book on OWAS3) that contained the repetitive parts of the code (e.g. headers, footers, standard processing) and overloaded the functions/procedures in it where required.

This package was placed into a separate schema and we granted execute privilege to PUBLIC on it so anyone could call the appropriate part (with parameters) and get a consistent result.

Part of this package were the following functions to allow for pre/post usage of the Spyglass or Apache web servers that Oracle used early on:

FUNCTION GetFormValue (p_name in varchar2,
p_num_entries in number,
p_name_array in owa.vc_arr,
p_value_array in owa.vc_arr ) return varchar2 is
-- This version for OWS and OAS calling convention
-- use the other function (without p_num_entries) for iAS (Apache)
begin
-- find the matching value for p_name (case insensitive search)
for counter in 1..p_num_entries loop
if upper(p_name) = upper(p_name_array(counter)) then
return trim(p_value_array(counter));
end if;
end loop;
-- no match found
return null;
end;
-- ////////////////////////////////////////////////////////////
-- ////////////////////////////////////////////////////////////
FUNCTION GetFormValue (p_name in varchar2,
p_name_array in owa.vc_arr,
p_value_array in owa.vc_arr ) return varchar2 is
-- Apache version for iAS
begin
-- find the matching value for p_name (case insensitive search)
for counter in 1..p_name_array.COUNT loop
if upper(p_name) = upper(p_name_array(counter)) then
return trim(p_value_array(counter));
end if;
end loop;
-- no match found
return null;
end;
-- ////////////////////////////////////////////////////////////

This could then be called to process a page as follows:
v_state varchar2(1) :=
waf.GetFormValue('p_state', name_array, value_array);
v_subnet_id addresses.NETWK_SUBNET_ID%TYPE :=
waf.GetFormValue('p_subnet_id', name_array, value_array);

You could do something similar to avoid having to "reinvent the wheel" every time you need to process a page.

These days I use Application Express which handles that and most other things for me - and it's free and supported with a ton of sample applications and tutorials.

Greg
Posted by marv732
20th Jan 2008