5.4. Presenting Query Results via a Web Page

Armed with new knowledge of how to fetch data from the database into PL/SQL, we can now contemplate presenting the data on a web page. How `bout we start by implementing a simple-minded web page that will dump all the data in the table? Well, it seems easy enough on the surface:

<%@ page language="PL/SQL" %>
<%@ plsql procedure="q" %>

<BODY bgcolor="white">

   FOR bk IN (SELECT * FROM books)
      <%= bk.isbn %>
      <%= bk.title %>
      <%= bk.author %>
      <%= bk.date_published %>
      <%= bk.page_count %>
      <%= bk.summary %>


But when you actually view this page (see Figure 5-3), you're in for a rude awakening, because it's so badly arranged that it's virtually unusable.

Figure 5-3. Output from naïve "table-dumping" approach

This is a reminder that browsers have no respect for the spaces and line breaks that may appear in your HTML. What we need is a healthy dose of "nice and neat." Fortunately, there is a simple fix that will take us a long way toward making the web page pretty. The solution involves the HTML TABLE element, which I didn't get a chance to cover in the introduction to HTML in Chapter 3.

5.4.1. Introduction to HTML Tables

An HTML table is a structure on a web page that usually renders as a grid of nice, neat rows and columns. The simplest HTML table ...

Get Learning Oracle PL/SQL now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.