14-6. Creating a Web Form Dropdown List from a Database Query
Problem
Your web form requires a dropdown list whose elements are drawn from a database table.
Solution
Use the htp.formSelectOpen
, htp.formSelectOption
and htp.formSelectClose
procedures in the PL/SQL Web Toolkit to generate the required HTML tags. For example, suppose you need to use the HR schema to create a dropdown list of job titles from the JOBS
table. Here's how you'd do it.
create or replace procedure job_list as
cursor driver is
select job_id, job_title
from jobs
order by job_title;
begin
common.header ('Job Title');
htp.formSelectOpen ('id', 'Job Title: ');
htp.formSelectOption ('', 'SELECTED');
for rec in driver LOOP
htp.formSelectOption (rec.job_title, ...
Get Oracle and PL/SQL Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.