Week 10 April 5 • Subquery and Thresholds • Graphics Builder and Forms R.

Download Report

Transcript Week 10 April 5 • Subquery and Thresholds • Graphics Builder and Forms R.

1
Week 10
April 5
• Subquery and Thresholds
• Graphics Builder and Forms
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
2
The Importance of ORDER BY
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
Relying on Fate…
3
View name
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
What’s the Problem?
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
4
5
Ordered by record labels!
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
140 rows
All 2001
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
6
Paste the New Query into the Dialog Box
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
7
Revised Graph
8
Too many lines!
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
9
What’s a Threshold and Why Do We Need It?
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
10
Not much usable information
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
Reduce the Number of Record Labels
Top 7 record labels in sales
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
11
Create a set of threshold values
12
Every record label must beat every value in this set,
OR simply every record label must beat the highest
(i.e., maximum) value in this set
Highest value
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
REC
2001
--- ----------RCA
98562.88
COL
2285882.3
GRP
448870.6
GTS
156955.23
WB
571478.66
ARI
638935.25
KUC
48260.05
VER
188098.59
DOM
106147.96
LIB
42279.47
S/A
116819.02
CAP
1019419.4
KOK
59802.31
SHA
62003.69
DSY
104735.01
MCA
343229.06
MER
69748.69
MOT
252342.84
NAS
75892.67
PM
350717.42
WH
364718.11
CHS
62510.26
GEF
70964.37
APL
257074.33
ATL 1017378.32
E/A
83585.13
EMI
70391.52
POL
469854.45
2002
2003
2004
2005
---------- ---------- ----------- ----------96126.71
99773.52
112097.35
108383.42
2336707.93 2472875.7 2635497.41 2621255.29 Yes
469021.43 480428.06
531105.46
518445.68 Yes
154830.01 174953.32
196814.02
200256.45
576644.41 580731.48
587747.77
563445.49 Yes
628407.24 625556.25
644993.73
601378.96 Yes
40662.4
36247.64
35417.3
30704.89
202036.86 209501.61
245316.62
269777.58
120980.78 118289.17
116859.98
120437.15
42602.71
35975.38
39944.48
57172.18
131737.36 122668.75
137014.64
167739.88
1007901.07 972170.61 1005423.39
976683.56 Yes
82005.05
78328.95
78980.63
85922.7
81029.3
94834.46
120347.68
128159.91
97572.02
83157.61
88339.8
98077.64
345217.11 365019.64
392166.76
381035.82
69507.16
66263.35
61333.23
55619.23
263438.36 259107.84
290508.9
300567.62
91443.5 118311.33
172166.27
191768.39
354469.91 355604.56
363074.29
378489.29
374305.23 405000.86
483654.29
490804.67
76541.45 109559.04
106997.1
93288.6
70399.53
70265.02
85641.58
88666.07
296953.73 311523.14
324438.59
291354.25
1023850.51 993520.05 1082629.88
1117300.7 Yes
81487.22
99320.6
110026.61
118170.16
71098.97
75852.13
69773.29
55397.99
467419.28 485843.36
502552.77
453941.7 Yes
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
13
YEAR
---2001
2003
2005
2002
2004
THRESHOLD
---------330283.016
346523.920
369748.584
337903.903
371730.234
Highest
Eliminate the
ones with red
Working Backwards
14
• Create a set of all record labels that have all sales values
greater than those found in the set of thresholds
All record labels must beat all threshold
values (or simply the minimum sales value
must beat the maximum threshold value)
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
Retrieve all record labels annual sales
of those with minimum sales exceeding15
all values found in the thresholds
Subquery: Select only those record
labels that exist in the set that
contains record labels with sales
values greater than all threshold
values
35 rows
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
Anatomy of the Subquery
16
Basic Query for the Data Model:
select category, year, sales
Retrieves only those category members
from view1 alias1
that are found in the set produced by
where exists
the first subquery
(select category, min(sales)
Creates a set of category
from view1 alias2
where alias1.category = alias2.category members whose minimum
sales must be greater than all
group by category
threshold values
having min(sales) > all
(select threshold from view2))  Creates a set of threshold values
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
17
In Graphics Builder
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
A Few Simple Steps for Creating a Graph
(From Last Week)
• Build the initial SQL command in SQL Plus
• In Graphics Builder
– Build the data model
– Build the graph
• Select the graph type
• Assign the independent and dependent to the
categories and values, respectively
• Format the various components of graph as needed
• Save and run the graph
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
18
Layout Editor
Tool palette
Chart tool - Create data model and graph
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
19
20
A few steps later…
After Building the Graph
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
Generating an OGR File
21
 From the File menu, select Administration, Generate
and File System
Be sure to generate a new OGR file every time a change is made to
the OGD file.
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
Generating an OGR File
 Save the file
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
22
23
In Form Builder
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
Create a Chart Item on the Canvas
24
Select Data Block and the create tool in the tool palette
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
Create a Chart Item on the Canvas
Select Build a new data block manually
and click on OK
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
25
Create a New Item in the Data Block
Select Items and click on the Create Tool
in the tool palette
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
26
Change the Item’s Property
Right-mouse click the item (e.g., ITEM5)
and select Property Palette
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
27
Change the Item Type Property
1. Change the Item Type property
from Text Item to Chart Item
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
28
Change the Canvas Property
29
2. Change the Canvas property from <Null> to
the canvas’ name (e.g., CANVAS2)
3. Close the Property Palette
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
Expand the Chart Item on the Canvas
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
30
Attach the OG.PLL File
Select Attached Libraries and click on the create tool
in the tool palette
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
31
Locate and Attach the OG.PLL File
1. Click on Browse and
search for the file
2. Select the file and click on Open
Hint. Locate the OG.PLL file through a search in Windows Explorer and copy it into your
working directory. It may be located under Developer’s \tools\devdem60\demo\forms
subdirectory.
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
32
Attach the OG.PLL File
3. Click on Attach and select Yes (remove path)
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
33
34
1. Add a push button
2. Right-mouse click the push button and
select PL/SQL Editor
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
Select a Trigger
Select the WHEN-MOUSE-CLICK
trigger and click OK
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
35
PL/SQL
Open and close the OGR file
Compile the PL/SQL code
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
36
Test the Form
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
37
Test the Form
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
38
Modify the Canvas Properties
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
39
Modify the Chart Item Properties
Remove the bevel
Change the Background Color to match the canvas
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
40
First Graph
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
41
PL/SQL
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
42
Second Graph
R. Ching, Ph.D. • MIS Area • California State University, Sacramento
43