O'Reilly logo

Learning Oracle PL/SQL by Steven Feuerstein, Bill Pribyl

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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" %>

<HTML>
<HEAD>
   <TITLE>Search</TITLE>
</HEAD>
<BODY bgcolor="white">

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

</BODY>
</HTML>

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required