Team Fly 

Page 84

Ask the Expert

Q: Once I set parameters, do I ever have to set them again?

A: Yes. Parameters are good only for the current setting. The parameters always reset to their default settings when you start up a new SQL*Plus session. However, the parameter defaults can be overwritten at the start of each SQL*Plus session by entering and saving them in the login.sql file.

The set pagesize command determines the length of the page. The default page size is 14 lines. If you don't want to repeat the result headings every 14 lines, use this command. If you want your page to be 50 lines long, issue the command set pagesize 50.

Page Titles

The ttitle command includes a number of options. The default settings return the date and page number on every page followed by the title text centered on the next line. Multiple headings can also be produced by separating the text with the vertical bar character. The command ttitle 'Customer List | Utah' centers the text ''Customer List" on the first line followed by "Utah" on the second line.

Page Footers

The btitle command will center text at the bottom of the page. The command btitle 'sample.sql' places the text "sample.sql" at the bottom center of the output listing. The command btitle left 'sample.sql' results in the footer text "sample.sql" being placed at the left edge of the footer.

Formatting Columns

Quite often, you'll need to format the actual column data. The column command is used to accomplish this. Suppose we are going to select the last name from the CUSTOMERS table along with a number of other columns. We know that, by default, the last name data will take up more space than it needs. The command column cust_last_name format a12 wrap heading 'Last | Name' tells SQL*Plus that there should be only 12 characters of the last name displayed and that the column title 'Last Name' should be displayed on two separate lines.

Project 2-5 Formatting Your SQL Output

Let's put these SQL*Plus concepts together and format the output of a SQL query. The following step-by-step instructions will lead you through a few of these basic formatting commands.

Team Fly 
0103-Project 2-5 Formatting Your SQL Output