Chapter Twenty Producing Readable Output

Slides:



Advertisements
Similar presentations
Reports Using SQL Script Please check speaker notes for additional information!
Advertisements

Outline Proc Report Tricks Kelley Weston. Outline Examples 1.Text that spans columnsText that spans columns 2.Patient-level detail in the titlesPatient-level.
Reports IT Key Ideas, Dynamic Database Systems, 2002 Chapter 5.
7 Copyright © Oracle Corporation, All rights reserved. Producing Readable Output with i SQL*Plus.
Mark Dixon Page 1 07 – Reports. Mark Dixon Page 2 Session Aims & Objectives Aims –To use reports to produce more readable documents Objectives, by end.
2 Copyright © 2004, Oracle. All rights reserved. Restricting and Sorting Data.
Format a Worksheet for Printing Lesson 3 - Microsoft Excel 2010.
SQL Query Extras MIS 433. Rerunning the last Query n Type the forward slash “/” to rerun the last query that was entered.
Chapter 1 Writing Basic SQL Statements Important Legal Notice:  Materials on this lecture are from a book titled “Oracle Education” by Kochhar, Gravina,
Ceng 356-Lab2. Objectives After completing this lesson, you should be able to do the following: Limit the rows that are retrieved by a query Sort the.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
Chapter 2 Basic SQL SELECT Statements
Chapter 2 Basic SQL SELECT Statements Oracle 10g: SQL.
Database A collection of related data. Database Applications Banking: all transactions Airlines: reservations, schedules Universities: registration, grades.
Chapter Four Objectives Introduction to SQL Types of SQL statements Concepts of DDL & DML Creating Tables Restrictions on Tables Data Definition Language(DDL)
Project Implementation for COSC 5050 Distributed Database Applications Lab3.
McGraw-Hill Technology Education © 2004 by the McGraw-Hill Companies, Inc. All rights reserved. Office Access 2003 Lab 3 Analyzing Data and Creating Reports.
Analyzing Data For Effective Decision Making Chapter 3.
Building Self-Updating Excel Workbooks John Filce and Ward Headstrom Institutional Research & Planning Humboldt State University.
ISYS 365 – SQL*Plus Environment. 2 Agenda What is SQL*Plus? Command Line Editor Useful SQL*Plus Commands Useful System Tables What is PL/SQL? PL/SQL Constructs.
COSC 1P02 Introduction to Computer Science 9.1 Cosc 1P02 "A lie gets halfway around the world before the truth has a chance to get its pants on.” Sir Winston.
1 Reports. 2 Objectives  Use concatenation in a query  Change column headings and formats  Add a title to a report  Group data in a report  Include.
Format a Worksheet for Printing Lesson 3 - Microsoft Excel 2013.
BACS 287 Structured Query Language 1. BACS 287 Visual Basic Table Access Visual Basic provides 2 mechanisms to access data in tables: – Record-at-a-time.
Oracle Command Spool Spool C:\temp\Lab9.lst Select Hotel_no, room_no, type, price From Room Order by Hotel_no; Spool Off.
A Guide to SQL, Seventh Edition. Objectives Understand how to use functions in queries Use the UPPER and LOWER functions with character data Use the ROUND.
8 Producing Readable Output with SQL*Plus. 8-2 Objectives At the end of this lesson, you should be able to: Produce queries that require an input variable.
Chapter Eight Data Manipulation Language (DML) Objectives Oracle DBMS Understanding the DML General format of SQL Capability of SELECT statement Use of.
1 Writing Basic SQL Statements. 1-2 Objectives At the end of this lesson, you should be able to: List the capabilities of SQL SELECT statements Execute.
2 Copyright © 2004, Oracle. All rights reserved. Restricting and Sorting Data.
1 Guide to Oracle10G CHAPTER 7: Creating Database Reports 7.
1 Lesson 13 Organizing and Enhancing Worksheets Computer Literacy BASICS: A Comprehensive Guide to IC 3, 3 rd Edition Morrison / Wells.
Copyright  Oracle Corporation, All rights reserved. 8 Producing Readable Output with SQL*Plus.
© 2010 Pearson Education, Inc. | Publishing as Prentice Hall.1 Computer Literacy for IC 3 Unit 2: Using Productivity Software Chapter 6: Creating and Formatting.
Chapter 14 Formatting Readable Output. Chapter Objectives  Add a column heading with a line break to a report  Format the appearance of numeric data.
Chapter Five Data Manipulation Language (DML) Objectives Oracle DBMS Understanding the DML General format of SQL Capability of SELECT statement Use of.
By: Ms. Abeer Helwa 1. WORD WEB APP 2 Word Web App is a limited version of Word, enabling you to edit, format, and share documents online. Word Web App.
Use of Data Security Commands Security: Information is vital to success, but when damaged or in the wrong hands, it can threaten success. OREACLE provides.
Format a Worksheet for Printing Lesson 3 - Microsoft Excel 2010.
Chapter Twelve Report Writing Objectives: -Writing reports -Page set up -Page layout.
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
2 Copyright © 2009, Oracle. All rights reserved. Restricting and Sorting Data.
Introduction to Technology. Parts of MSWord Screen Title Bar Quick Access Toolbar Button Ribbon Status Bar (views and zoom)
ACCESS REPORT GENERATOR. IT Fundamentals2 Reports Overview Reports are an important part of any computer business application. Features that are important.
Oracle PL/SQL SQL*Plus. EDIT Opens notepad with the buffer contents To use type: –Edit –Ed Opens notepad with the buffer contents To use type: –Edit –Ed.
Chapter Five Objectives Insert Data into tables Create Query files to insert data into tables Make changes to the data in the tables Extract data from.
1 Chapter 3 Single Table Queries. 2 Simple Queries Query - a question represented in a way that the DBMS can understand Basic format SELECT-FROM Optional.
Chapter 21: Report writing1 Chapter Twenty One Producing Readable Output Objectives: Writing reports Page set up Page layout Queries with input.
A Guide to SQL, Sixth Edition 1 Chapter 7 Reports.
CSE 4701 Chapter 10-1 Chapter 10 6e: Oracle Prof. Steven A. Demurjian, Sr. Computer Science & Engineering Department The University of Connecticut 191.
Database Design lecture 3_2 Slide 1 Database Design Lecture 3_2 Data Manipulation in SQL Simple SQL queries References: Text Chapter 8 Oracle SQL Manual.
SQL Tutorial CPSC 608 Database System. Connecting to Oracle Your username is identical to your UNIX account To access your Oracle account, you need to.
A Guide to SQL, Seventh Edition
Key Applications Module Lesson 17 — Organizing Worksheets
SQL and SQL*Plus Interaction
Using SQL*Plus.
SQL in Oracle.
Introduction to Oracle9i: SQL
Format a Worksheet for Printing
ISYS 365 – SQL*Plus Environment
Using SQL*Plus.
Creating and Maintaining
Access Tutorial 5 Creating Advanced Queries and Enhancing Table Design
Restricting and Sorting Data
ORACLE.
Contents Preface I Introduction Lesson Objectives I-2
Using SQL*Plus.
Fordham Connect Train-the-Trainer Training Reports
Grauer and Barber Series Microsoft Access Chapter Two
Producing Readable Output with iSQL*Plus
Presentation transcript:

Chapter Twenty Producing Readable Output Chapter 21: Report writing Chapter Twenty Producing Readable Output Objectives: Writing reports Page setup Page layout Queries with input Chapter 21: Report writing COSC 641

Producing Readable Output Chapter 21: Report writing Producing Readable Output Your Name January 7,2001 List of courses Department Course No. Course Name Credit Date Started Max enrollment COSC 100 Intro 3 2-10-92 30 110 Intro II 2-11-98 15 200 Programming 14-2-93 20 220 Application 10-10-01 Total 12 MATH Algebra 4 1-9-91 45 Grand Total Report1.sql Page 1 COSC 641

Summary of Formatting Output Commands Chapter 21: Report writing Summary of Formatting Output Commands COLUMN TTITLE BTITLE BREAK ON COMPUTE Chapter 21: Report writing COSC 641

Chapter 21: Report writing COLUMN: COLumn name | expression CLEar FORmat format HEAding Text JUStify L | C | R NEWLine NEW_VALUE continue Chapter 21: Report writing COSC 641

Chapter 21: Report writing COLUMN:(continued) NULl text NOPRInt PRInt WRApped TRUncated Chapter 21: Report writing COSC 641

Chapter 21: Report writing Formatting Option: COLUMN Name FORMAT A10 COLUMN id FORMAT 9999 COLUMN cr FORMAT 9 COLUMN Gpa FORMAT 9.99 FORMAT: $9999 9 0999 990 9,999.99 DATE A10 L999 Chapter 21: Report writing COSC 641

Chapter 21: Report writing Formatting Option: COLUMN Name FORMAT A10 COLUMN id FORMAT 9999 COLUMN cr FORMAT 9 COLUMN GPA FORMAT 9.99 SELECT Name, id, cr, GPA FROM student WHERE Major=‘COSC’ ORDER BY GPA; Chapter 21: Report writing COSC 641

Chapter 21: Report writing Heading Option: COLumn Name HEAding ‘Student’’s Name’ COLumn id HEAding ‘Student’’s ID’ COLumn cr*grade HEAding ‘Score’ COLumn name HEAding ‘Student’’s Name’ JUSTIFY R COLumn Name HEAding ‘Name’ FORmat A10 COLumn Major FORmat A7 NULL ‘NO Major’ COL address HEADING ‘Addr’ FORmat A7 TRUncated Chapter 21: Report writing COSC 641

Chapter 21: Report writing Column Example: COLumn id HEADING ‘Stud ID’ FORMAT 9999 TRUNCATED Chapter 21: Report writing COSC 641

Chapter 21: Report writing Clear Setting COLumn Major CLEar COLumn Chapter 21: Report writing COSC 641

Chapter 21: Report writing Break on BREAK ON id SKIP 2 BREAK ON id DUPLICATES SKIP 2 BREAK ON id NODUPLICATES BREAK ON Major ON ID BREAK ON REPORT PAGE ON dept PAGE Chapter 20: Report writing COSC 641

Chapter 21: Report writing Break on Format: BREAK ON column BREAK ON row BREAK ON page BREAK ON report SKIP n SKIP page CLEAR BREAK Chapter 21: Report writing COSC 641

Chapter 21: Report writing Compute COMPUTE SUM OF gpa ON id COMPUTE SUM LABEL ‘Total’ OF gpa ON id COMPUTE AVG OF a, b, c, d ON e COMPUTE SUM AVG COUNT OF gpa ON id AVG COUNT MAX MIN STD VAR Chapter 21: Report writing COSC 641

Chapter 21: Report writing Check the Setting: COLUMN BREAK SHOW DEFINE Chapter 21: Report writing COSC 641

Chapter 21: Report writing Page Setup Line size: SET LINESIZE 75 Page size: SET PAGESIZE 60 Blank lines at the top: SET NEWPAGE 3 Writing into a file: SPOOL filename.lis SPOOL Gstudent.lis SPOOL OFF Chapter 21: Report writing COSC 641

Chapter 21: Report writing Page Setup Display: SET TERMOUT ON SPOOL filename.lis SET TERMOUT OFF Heading separator: SET HEADSEP char SET HEADSEP ! Underlining: SET UNDERLINE OFF Chapter 21: Report writing COSC 641

Chapter 21: Report writing Page Setup Title: TTITLE text | variable TTITLE ‘Information‘ BTITLE ‘Confidential‘ TTITLE Left ‘Page: ’ SQL.PNO – Right ‘Date: ‘ SYSDATE Skip 1 – Center ‘ My Report ‘ Skip 3; SQL.LNO SQL.PNO SQL.RELEASE SQL.SQLCODE SQL.USER Chapter 21: Report writing COSC 641

Chapter 21: Report writing Page Setup Host: HOST myedit filename.SQL HOST list 2 Start: START filename.SQL Chapter 21: Report writing COSC 641

Chapter 21: Report writing Page Setup Summary: COLUMN COLUMN colname TTITLE BTITLE BREAK COMPUTE DEFINE SHOW HEADSEP SHOW LINESIZE SHOW PAGESIZE SHOW NEWPAGE Chapter 21: Report writing COSC 641

Chapter 21: Report writing Set Commands COLSEP [ |Text] FEEDBACK [OFF| ON| n] HEADING [OFF| ON] LINESIZE [n] PAGESIZE [n] PAUSE [OFF| ON| Text] TERMOUT [OFF| ON] Chapter 21: Report writing COSC 641

Report Writing Example: Chapter 21: Report writing Report Writing Example: Your Name January 7,2001 List of courses Department Course No. Course Name Credit Date Started Max enrollment COSC 100 Intro 3 2-10-92 30 110 Intro II 2-11-98 15 200 Programming 14-2-93 20 220 Application 10-10-01 Total 12 MATH Algebra 4 1-9-91 45 Grand Total Report1.sql Page 1 Chapter 21: Report writing COSC 641

Report Writing Example: Chapter 21: Report writing Report Writing Example: CLEAR BREAK CLEAR COMPUTE COLUMN dept HEADING ‘Department’ FORMAT A12 COLUMN c_num HEADING ‘Course|No.’ FORMAT 999 COLUMN title HEADING ‘Course|Name’ FORMAT A13 COLUMN cr HEADING ‘Credit’ FORMAT 99 COLUMN D_start HEADING ‘Date|Started’ FORMAT DATE COLumn m_enrol HEAding ‘Max|Enrollment’ FORMAT 999 Chapter 21: Report writing COSC 641

Report Writing Example: Chapter 21: Report writing Report Writing Example: COL SYSDATE NEW_VALUE xdate NOPRINT - FORMAT A10 TRUNC BREAK ON dept SKIP 2 COMPUTE SUM LABEL ‘Total’ OF cr ON dept COMPUTE SUM LABEL ‘Grand Total’ OF cr ON dept REPORT TTITLE LEFT ‘Your Name:’ - RIGHT xdate SKIP 2 - CENTER ‘List of Courses’ SKIP 1 Chapter 21: Report writing COSC 641

Report Writing Example: Chapter 21: Report writing Report Writing Example: BTITLE LEFT ‘Report1.sql’ - RIGHT ‘Page:’ SQL.PNO SELECT dept, c_num, title, cr, d_start.m_enroll,SYSDATE FROM department WHERE dept IN (‘COSC’, ‘MATH’) ORDER BY dept; Chapter 21: Report writing COSC 641

Chapter 21: Report writing Login File Login.sql prompt login.sql loaded set feedback off set sqlprompt ‘ ‘ set sqlnumber off set numwidth 5 set pagesize 24 set linesize 79 Chapter 21: Report writing COSC 641

Substitution Variables Chapter 21: Report writing Substitution Variables Use substitution variables to temporarily store values - & - & & - DEFINE and ACCEPT Pass variable values between SQL statements Dynamically alter headers and footers Chapter 21: Report writing COSC 641

Chapter 21: Report writing USING & VARIABLE: SELECT name, id, address FROM student WHERE id=&student_id; Enter value for student_id: Chapter 21: Report writing COSC 641

& Substitution Variables Chapter 21: Report writing & Substitution Variables User provides the input to the query SELECT Name, GPA, ID FROM Student WHERE UPPER(Major) = &Major_Input; Enter Value for Major_Input: ‘COSC’ Chapter 21: Report writing COSC 641

& Substitution Variables Chapter 21: Report writing & Substitution Variables SELECT Name, ID, &Column_name FROM Student WHERE &condition ORDER BY ℴ Enter Value for Column_name: Enter Value for Condition: Enter Value for Order: Chapter 21: Report writing COSC 641

&& Substitution Variables Chapter 21: Report writing && Substitution Variables Use a value of a variable more than one time SELECT Name, ID, &&Column_name FROM Student WHERE &Column_name=&NewName; Enter value for Column_name: Enter value for NewName: Chapter 21: Report writing COSC 641

Chapter 21: Report writing SET VERIFY ON: SQL> SET VERIFY ON SQL> SELECT name, id, address 2 FROM student 3 WHERE id=&student_id; Enter value for student_id: 1111 Old 3: where id=&student_id; New 3: where id= 1111 Chapter 21: Report writing COSC 641

Character and Date Values With Substitution Variables: Chapter 21: Report writing Character and Date Values With Substitution Variables: SELECT name, id, b_date FROM student WHERE b_date = '&new_birthdate'; Enter value for new_birthdate: Chapter 21: Report writing COSC 641

Specifying Column Names, Expressions, and Text at Runtime Chapter 21: Report writing Specifying Column Names, Expressions, and Text at Runtime WHERE condition ORDER BY clause COLUMN expression TABLE name Entire SELECT statement Chapter 21: Report writing COSC 641

Chapter 21: Report writing Example SELECT name, id, rank, &column_name FROM faculty WHERE &condition ORDER BY &order_column; Enter value for column_name: Enter value for condition: Enter value for order_column: Chapter 21: Report writing COSC 641

Defining User Variables Chapter 21: Report writing Defining User Variables You can pre-define variables using: DEFINE: Create a user variable of CHAR data type ACCEPT: Read user input and store it in a variable Chapter 21: Report writing COSC 641

Defining User Variables Chapter 21: Report writing Defining User Variables If you need to predefine a variable that includes spaces, you need to enclose the value within single quotation marks, when using the DEFINE command. DEFINE variable=CAR DEFINE variable DEFINE ACCEPT Chapter 21: Report writing COSC 641

Chapter 21: Report writing ACCEPT Command: Create a customized prompt when accepting user input Explicitly defines a NUMBER or DATE data type variable Hides user input for security Chapter 21: Report writing COSC 641

Chapter 21: Report writing ACCEPT Command: ACCEPT variable [ data type] [FORMAT format][prompt text ] [HIDE] ACCEPT field PROMPT 'Input your Major:‘ SELECT * FROM student WHERE major=UPPER ('&field') Input your major: Chapter 21: Report writing COSC 641

Chapter 21: Report writing DEFINE and UNDEFINE Use the UNDEFINE command to clear Exit SQL*plus To define variables for every session, modify your login.sql file Chapter 21: Report writing COSC 641

Chapter 21: Report writing Create a Variable DEFINE dept_name=COSC DEFINE dept_name SELECT * FROM faculty WHERE dept=UPPER ('&dept_name'); UNDEFINE dept_name Chapter 21: Report writing COSC 641