Create Drop Downs and HTML tables from SQL Queries
This is an example of how to use owa_util to create dropdowns and to display the contents of a table/
Fisrt we create a html dropdown list based on a sql query by using owa_util.listprint
Then we use owa_util.bind_variables to bind the parameter gather from the dropdown list into another SQL query and we use
owa_util.cellsprint to create the html code to display the results.
procedure droptest( p_my_list in varchar2 default null ) is
begin
htp.p('<html><body>');
htp.p('<form name="test" method="POST" action="SERVICE.TESTJB.droptest">');
htp.p( 'Select City:' );
htp.para;
owa_util.listprint
( 'select distinct
upper(OFFICE_CITY) OFFICE_CITY,
upper(OFFICE_CITY) OFFICE_CITY,
null from users
where status = ''ENABLED''',
'p_my_list', 1, false );
htp.para;
htp.formsubmit;
htp.p('</form>');
if p_my_list is not null then
htp.p('City = ' || p_my_list);
htp.para;
htp.p('<table>');
owa_util.cellsprint(owa_util.bind_variables(
'select user_name, user_name, TITLE from users
where upper(OFFICE_CITY) = :l_city', ':l_city', p_my_list));
htp.p('</table>');
end if;
htp.p('</body> </html>');
exception when others then htp.p('Error = '||sqlerrm);
end;
Regards, Homer
No comments:
Post a Comment