Tt
Click this widget to change the font size.
CC
Click this widget to change contrast.

Home Page 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | Links | Search | Bio |

Guide to HTML, CSS, and JavaScript (Buffalo State College Version)


Adding JavaScript Validation to Your Web Form Page

Using SELECT statements can produce output that is needed by other people. Oracle SQL provides a robust commands that allow you to control the number of lines the width of the page, column headngs, column widths, and report title, just to name a few.

CommandDescription
BREAK ON columnDisplay data one time and then blanks in place of duplicate values.
COLUMN column CLEARClears a previousll defined columformat or heading.
COLUMN column FORMAT formatFormat the data based on the format parameter.
COLUMN column HEADING "text"Similar to using a column alias.
SET PAGESIZE numberNumber of lines before a page break.
SET LINESIZE numberWidth of a report line.
SET =Changes the underline from a hyphen (-) to an equal sign (=).
TTITLE "Report Title"Places a title before the report output.

Figure 11-1: SQL Report Formatting Commands

The COLUMN FORMAT format Command

The COLUMN FORMAT format command allows you to define a format a similar to TO_CHAR() and define the width of that column.

-- Before formatting
SELECT jimid, lastname, firstname FROM jimtable;

     JIMID LASTNAME                  FIRSTNAME
---------- ------------------------- -------------------------
         1 Gerland                   James
         2 Phailure                  Phil
         3 Smart                     Sally

-- After formatting
COLUMN jimid FORMAT 9
COLUMN lastname FORMAT A15
COLUMN firstname FORMAT A15
SELECT jimid, lastname, firstname FROM jimtable;

JIMID LASTNAME        FIRSTNAME
----- --------------- ---------------
    1 Gerland         James
    2 Phailure        Phil
    3 Smart           Sally
Figure 11-2: Using COLUMN FORMAT To Format Fields
-- Before formatting
SELECT jimid, lastname, firstname FROM jimtable;

     JIMID LASTNAME                  FIRSTNAME
---------- ------------------------- -------------------------
         1 Gerland                   James
         2 Phailure                  Phil
         3 Smart                     Sally

-- After formatting
COLUMN jimid FORMAT 9
COLUMN jimid HEADING "ID"
COLUMN lastname FORMAT A15
COLUMN lastname HEADING "Last Name"
COLUMN firstname FORMAT A15
COLUMN firstname HEADING "First Name"
SELECT jimid, lastname, firstname FROM jimtable;

ID Last Name       First Name
-- --------------- ---------------
 1 Gerland         James
 2 Phailure        Phil
 3 Smart           Sally
Figure 11-3: Using COLUMN HEADING To Format Column Headings

The TTITLE "text" Command

The TTITLE text command (yes, there are two (2) "T"s in TTITLE), allows you to define a page title for your report.

-- Before formatting
SELECT jimid, lastname, firstname FROM jimtable;

     JIMID LASTNAME                  FIRSTNAME
---------- ------------------------- -------------------------
         1 Gerland                   James
         2 Phailure                  Phil
         3 Smart                     Sally

-- After formatting
COLUMN jimid FORMAT 9
COLUMN jimid HEADING "ID"
COLUMN lastname FORMAT A15
COLUMN lastname HEADING "Last Name"
COLUMN firstname FORMAT A15
COLUMN firstname HEADING "First Name"
TTITLE "Employees In The jimTable"
SELECT jimid, lastname, firstname FROM jimtable;

Sat Jan 30                                                             page    1
                           Employees In The jimTable

ID Last Name       First Name
-- --------------- ---------------
 1 Gerland         James
 2 Phailure        Phil
 3 Smart           Sally
Figure 11-4: Using TTITLE "heading" To Format Fields

The BREAK ON field Command

The BREAK ON field command provides a way to list only the first occurance of that field and group the records on the field.

-- Before BREAK ON
SELECT SELECT department_name, last_name, first_name 
FROM departments d 
INNER JOIN employees e on d.department_id = e.department_id
ORDER BY department_name;

DEPARTMENT_NAME                LAST_NAME                 FIRST_NAME          
------------------------------ ------------------------- --------------------
Accounting                     Hall                      Darryl              
Accounting                     Felix                     Allison             
Executive                      Taylor                    James               
Executive                      Scott                     Steve               
Marketing                      Jones                     LoLo                
Purchasing                     Hall                      Sarah               
Purchasing                     Wertz                     Charlie             
Purchasing                     Taylor                    Livingston          
Purchasing                     Oates                     John                
Shipping                       Lindgren                  Gerry               

10 rows selected.

-- After BREAK ON
BREAK ON department_name
SELECT SELECT department_name, last_name, first_name 
FROM departments d 
INNER JOIN employees e on d.department_id = e.department_id
ORDER BY department_name;
                                            
DEPARTMENT_NAME                LAST_NAME                 FIRST_NAME          
------------------------------ ------------------------- --------------------
Accounting                     Hall                      Darryl              
                               Felix                     Allison             
Executive                      Taylor                    James               
                               Scott                     Steve               
Marketing                      Jones                     LoLo                
Purchasing                     Hall                      Sarah               
                               Wertz                     Charlie             
                               Taylor                    Livingston          
                               Oates                     John                
Shipping                       Lindgren                  Gerry               

10 rows selected.
Figure 11-5: Using BREAK ON field To Group Records