Download presentation
Presentation is loading. Please wait.
Published byCharla Douglas Modified over 8 years ago
1
Chapter Twelve Report Writing Objectives: -Writing reports -Page set up -Page layout
2
2 Report Writing Your NameJanuary 7,2001 List of courses DepartmentCourse No. Course Name CreditDate Started Max enrollment COSC100Intro32-10-9230 110Intro II32-11-9815 200Programming314-2-9320 220Application310-10-0120 Total1218 MATH100Algebra41-9-9145 Grand Total110
3
3 COLUMN: COLumnname | expression FORmatformat HEAdingText JUStify L | C | R NEWLine WRApped | TRUncated ;
4
4 Column: COLUMN NameHEADING ‘Student’’s Name’ COLUMN idHEADING ‘Student’’s ID’ COLUMN cr*gradeHEADING ‘Score’ COLUMN nameHEADING ‘Student’’s Name’ JUSTIFY L
5
5 Column: COLUMN NameFORMAT A20 COLUMN idFORMAT 9999 COLUMN crFORMAT 9 COLUMN GpaFORMAT 9.99 FORMAT: $9999 0999 990 9,999.99 DATE A10
6
6 Column: COLUMNNameTRUNCATED COLUMN idHEADING ‘Stud ID’ FORMAT 9999
7
7 Break on: BREAK ONid SKIP 2 BREAK ON id DUPLICATE SKIP 2 BREAK ON id DUPLICATE SKIP 2 ON REPORT
8
8 Compute: COMPUTE SUM OF gpa ON id COMPUTE SUM LABEL ‘Total’ OF gpa ON id COMPUTE AVG OF a, b, c, d ON e, f AVG COUNT MAX MIN STD VAR
9
9 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
10
10 Page Setup Display: SET TERMOUT ON SPOOL filename.lis SET TERMOUT OFF Heading separator: SET HEADSEP char SET HEADSEP !
11
11 Page Setup Title: TTITLE‘ ‘ BTITLE ‘ ‘ TTITLELeft ‘Page:’ SQL.PNO – Right ‘Date: ‘ SYSDATE Skip 1 – Center ‘ My Report ‘ Skip 3;
12
12 Page Setup Host: HOST myedit filename.SQL Start: START filename.SQL SQL environment: COLUMN COLUMN colname TTITLE BTITLE BREAK COMPUTE DEFINE SHOW HEADSEP SHOW LINESIZE SHOW PAGESIZE SHOW NEWPAGE
13
13 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
14
14 Substitution Variables Substitution variables to temporarily store values - & - & & - DEFINE and ACCEPT Pass variable values between SQL statements Dynamically alter header and footers
15
15 & Substitution Variables User provides the input to the query SELECTName, GPA, ID FROMStudent WHEREUPPER(Major) = &Major_Input; Enter Value for Major_Input: ‘COSC’
16
16 & Substitution Variables SELECTName, ID, &Column_name FROMStudent WHERE&condition ORDER BYℴ Enter Value for Column_name: Enter Value for Condition: Enter Value for Order:
17
17 && Substitution Variables Use a value of a variable more than one time SELECTName, ID, &&Column_name FROMStudent WHERE&Column_name; Enter value for Column_name:
18
18 SET VERIFY ON: SET VERIFY ON SELECTname, id, address FROMstudent WHEREid=&student_id; Enter value for student_id: Old: where id=&student_id; New: when id=
19
19 Character and Date Values With Substitution Variables: SELECTname, id, b_date FROMstudent WHEREb_date = '&new_birthdate'; Enter value for new_birthdate:
20
20 SELECTname, id, rank, &column_name FROMfaculty WHERE&condition ORDER BY&order_column; Enter value for column_name: Enter value for condition: Enter value for order_column:
21
21 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
22
22 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. DEFINEvariable=value DEFINEvariable DEFINE ACCEPT
23
23 ACCEPT Command: Create a customized prompt when accepting user input Explicitly defines a NUMBER or DATE datatype variable Hides user input for security
24
24 ACCEPT Command: ACCEPT variable [ datatype] [FORMAT format] [prompt text ] [HIDE] ACCEPTfield PROMPT 'Input your Major:‘ SELECT* FROMstudent WHEREmajor=UPPER ('&field') Input your major:
25
25 DEFINE and UNDEFINE Use the UNDEFINE command to clear Exit SQL*plus To define variables for every session, modify your login.sql file
26
26 DEFINE: DEFINEdept_name=COSC DEFINEdept_name SELECT* FROMfaculty WHEREdept=UPPER ('&dept_name'); UNDEFINE dept_name
27
27 Example SQL> SET PAGESIZE 40 SQL> SET LINESIZE 60 SQL> SET FEEDBACK OFF SQL> Define MyName = 'Dr. Chitsaz' SQL> TTITLE LEFT 'MyName: ' & MyName - RIGHT SYSDATE Skip1 – CENTER ‘List Of Courses' SQL> COLUMN dept HEADING 'Deaprtment' format A10 SQL> COLUMN C_Num HEADING 'Course|Number' format 9999 SQL> COLUMN title HEADING 'Course|Name' FORMAT A5 SQL> COLUMN Cr HEADING 'Credit' FORMAT 9
28
28 Example SQL> COLUMN S_DATE HEADING 'Date | Started' SQL> COLUMN Max HEADING 'Max | Enrollment' format 999 SQL> BREAK ON dept SQL> COMPUTE SUM LABLE 'Total' OF Cr ON Dept SQL> BREAK ON REPORT SQL> COMPUTE sum LABLE 'Grand Total' SQL> select DEPT, C_Num, TITLE, CR, S_DATE, Max 2 FROM Course 3 ORDER BY DEPt;
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.