Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Apress committed Oct 7, 2016
0 parents commit 4886241
Show file tree
Hide file tree
Showing 17 changed files with 234 additions and 0 deletions.
Binary file added 2976.pdf
Binary file not shown.
Binary file added 2977.pdf
Binary file not shown.
Binary file added 9781590595244.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions LICENSE.txt
@@ -0,0 +1,27 @@
Freeware License, some rights reserved

Copyright (c) 2006 John Shaw and Julian Dyke

Permission is hereby granted, free of charge, to anyone obtaining a copy
of this software and associated documentation files (the "Software"),
to work with the Software within the limits of freeware distribution and fair use.
This includes the rights to use, copy, and modify the Software for personal use.
Users are also allowed and encouraged to submit corrections and modifications
to the Software for the benefit of other users.

It is not allowed to reuse, modify, or redistribute the Software for
commercial use in any way, or for a user�s educational materials such as books
or blog articles without prior permission from the copyright holder.

The above copyright notice and this permission notice need to be included
in all copies or substantial portions of the software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


15 changes: 15 additions & 0 deletions README.md
@@ -0,0 +1,15 @@
#Apress Source Code

This repository accompanies [*Pro Oracle Database 10g RAC on Linux*](http://www.apress.com/9781590595244) by John Shaw and Julian Dyke (Apress, 2006).

![Cover image](9781590595244.jpg)

Download the files as a zip using the green button, or clone the repository to your machine using Git.

##Releases

Release v1.0 corresponds to the code in the published book, without corrections or updates.

##Contributions

See the file Contributing.md for more information on how you can contribute to this repository.
14 changes: 14 additions & 0 deletions contributing.md
@@ -0,0 +1,14 @@
# Contributing to Apress Source Code

Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers.

## How to Contribute

1. Make sure you have a GitHub account.
2. Fork the repository for the relevant book.
3. Create a new branch on which to make your change, e.g.
`git checkout -b my_code_contribution`
4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted.
5. Submit a pull request.

Thank you for your contribution!
1 change: 1 addition & 0 deletions examples/ch23_ex1.sql
@@ -0,0 +1 @@
SELECT time_id, channel_id, prod_id, ROUND (SUM(amount_sold)) AS TOTAL FROM SALES WHERE time_id BETWEEN '01-JAN-98' AND '31-JAN-98' AND prod_id IN (SELECT prod_id FROM products WHERE prod_name IN ('5MP Telephoto Digital Camera','17" LCD w/built-in HDTV Tuner','Envoy 256MB - 40GB','Y Box','Mini DV Camcorder with 3.5" Swivel LCD')) GROUP BY ROLLUP (time_id, (channel_id, prod_id));
49 changes: 49 additions & 0 deletions examples/ch23_ex10.tcl
@@ -0,0 +1,49 @@
#!/usr/local/bin/tclsh8.4
package require Oratcl
#EDITABLEOPTIONS##################################################
set connect system/manager@rac1
set rampup 2; #rampup time in minutes
set duration 10; #duration in minutes
#EDITABLEOPTIONS##################################################
set ramptime 0
puts "Beginning rampup time of $rampup minutes"
set rampup [ expr $rampup*60000 ]
while {$ramptime != $rampup} {
after 60000
set ramptime [ expr $ramptime+60000 ]
puts "Rampup [ expr $ramptime / 60000 ] minutes complete ..."
}
puts "Rampup complete, Taking start AWR snapshot."
set lda [oralogon $connect]
oraautocom $lda on
set curn1 [oraopen $lda ]
set sql1 "BEGIN dbms_workload_repository.create_snapshot(); END;"
oraparse $curn1 $sql1
if {[catch {oraplexec $curn1 $sql1} message]} { error "Failed to create snapshot : $message" }
set sql2 "SELECT INSTANCE_NUMBER, INSTANCE_NAME, DB_NAME, DBID, SNAP_ID, TO_CHAR(END_INTERVAL_TIME,'DD MON YYYY HH24:MI') FROM ( SELECT DI.INSTANCE_NUMBER, INSTANCE_NAME, DB_NAME, DI.DBID, SNAP_ID, END_INTERVAL_TIME FROM DBA_HIST_SNAPSHOT DS, DBA_HIST_DATABASE_INSTANCE DI ORDER BY SNAP_ID DESC ) WHERE ROWNUM = 1"
if {[catch {orasql $curn1 $sql2} message]} {
error "SQL statement failed: $sql2 : $message"
} else {
orafetch $curn1 -datavariable firstsnap
split $firstsnap " "
puts "Start Snapshot [ lindex $firstsnap 4 ] taken at [ lindex $firstsnap 5 ] of instance [ lindex $firstsnap 1 ] ([lindex $firstsnap 0]) of database [ lindex $firstsnap 2 ] ([lindex $firstsnap 3])"
}
puts "Timing test period of $duration in minutes"
set testtime 0
set duration [ expr $duration*60000 ]
while {$testtime != $duration} {
after 60000
set testtime [ expr $testtime+60000 ]
puts -nonewline "[ expr $testtime / 60000 ] ...,"
}
puts "Test complete, Taking end AWR snapshot."
oraparse $curn1 $sql1
if {[catch {oraplexec $curn1 $sql1} message]} { error "Failed to create snapshot : $message" }
if {[catch {orasql $curn1 $sql2} message]} {
error "SQL statement failed: $sql2 : $message"
} else {
orafetch $curn1 -datavariable endsnap
split $endsnap " "
puts "End Snapshot [ lindex $endsnap 4 ] taken at [ lindex $endsnap 5 ] of instance [ lindex $endsnap 1 ] ([lindex $endsnap 0]) of database [ lindex $endsnap 2 ] ([lindex $endsnap 3])"
puts "Test complete: view report from SNAPID [ lindex $firstsnap 4 ] to [ lindex $endsnap 4 ]"
}
19 changes: 19 additions & 0 deletions examples/ch23_ex2.sql
@@ -0,0 +1,19 @@
-- Listing hoex1.sql
variable t_id1 char(9);
execute :t_id1 := '01-JAN-98';
variable t_id2 char(9);
execute :t_id2 := '31-JAN-98';
variable pname1 varchar2(50);
execute :pname1 := '5MP Telephoto Digital Camera';
variable pname2 varchar2(50);
execute :pname2 := '17" LCD w/built-in HDTV Tuner';
variable pname3 varchar2(50);
execute :pname3 := 'Envoy 256MB - 40GB';
variable pname4 varchar2(50);
execute :pname4 := 'Y Box';
variable pname5 varchar2(50);
execute :pname5 := 'Mini DV Camcorder with 3.5" Swivel LCD';
ALTER SESSION SET EVENTS '10046 trace name context forever, level 4';
SELECT time_id, channel_id, prod_id, ROUND (SUM(amount_sold)) AS TOTAL FROM SALES WHERE time_id BETWEEN TO_DATE(:t_id1) AND TO_DATE(:t_id2) AND prod_id IN (SELECT prod_id FROM products WHERE prod_name IN (:pname1,:pname2,:pname3,:pname4,:pname5)) GROUP BY ROLLUP (time_id, (channel_id, prod_id));
ALTER SESSION SET EVENTS '10046 trace name context off';

25 changes: 25 additions & 0 deletions examples/ch23_ex3.tcl
@@ -0,0 +1,25 @@
#!/usr/local/bin/tclsh8.4
package require Oratcl
####UPDATE THE CONNECT STRING BELOW###
set connect user/password@rac1
set lda [oralogon $connect]
set curn1 [oraopen $lda ]
set sql1 "ALTER SESSION SET EVENTS '10046 trace name context forever, level 4' "
orasql $curn1 $sql1
set curn2 [oraopen $lda ]
set sql2 "SELECT time_id, channel_id, prod_id, ROUND
(SUM(amount_sold)) AS TOTAL FROM SALES WHERE time_id BETWEEN TO_DATE(:t_id1) AND TO_DATE(:t_id2) AND prod_id IN (SELECT prod_id FROM products WHERE prod_name IN (:pname1,:pname2,:pname3,:pname4,:pname5)) GROUP BY ROLLUP (time_id, (channel_id, prod_id)) "
orasql $curn2 $sql2 -parseonly
orabindexec $curn2 :pname3 {Envoy 256MB - 40GB} :pname4 {Y Box} :t_id1 {01-JAN-98} :pname5 {Mini DV Camcorder with 3.5" Swivel LCD} :pname1 {5MP Telephoto Digital Camera} :t_id2 {31-JAN-98} :pname2 {17" LCD w/built-in HDTV Tuner}
set row [orafetch $curn2 -datavariable output ]
while { [ oramsg $curn2 ] == 0 } {
puts $output
set row [orafetch $curn2 -datavariable output ]
}
oraclose $curn1
set curn1 [oraopen $lda ]
set sql1 "ALTER SESSION SET EVENTS '10046 trace name context off' "
orasql $curn1 $sql1
oraclose $curn1
oralogoff $lda

12 changes: 12 additions & 0 deletions examples/ch23_ex3_input1.txt
@@ -0,0 +1,12 @@
01-JAN-00:31-JAN-00:5MP Telephoto Digital Camera:17" LCD w/built-in HDTV Tuner:Envoy 256MB - 40GB:Y Box:Mini DV Camcorder with 3.5" Swivel LCD
01-FEB-00:29-FEB-00:Envoy Ambassador:Laptop carrying case:Home Theatre Package with DVD-Audio/Video Play:18" Flat Panel Graphics Monitor:Envoy External Keyboard
01-MAR-00:31-MAR-00:External 101-key keyboard:PCMCIA modem/fax 28800 baud:SIMM- 8MB PCMCIAII card:SIMM- 16MB PCMCIAII card:Multimedia speakers- 3" cones
01-APR-00:30-APR-00:Unix/Windows 1-user pack:8.3 Minitower Speaker:Mouse Pad:1.44MB External 3.5" Diskette:Multimedia speakers- 5" cones
01-MAY-00:31-MAY-00:PCMCIA modem/fax 19200 baud:External 6X CD-ROM:External 8X CD-ROM:Envoy External 6X CD-ROM:Envoy External 8X CD-ROM
01-JUN-00:30-JUN-00:Internal 6X CD-ROM:Internal 8X CD-ROM:O/S Documentation Set - English:O/S Documentation Set - German:O/S Documentation Set - French:O/S Documentation Set - Spanish
01-JUL-00:31-JUL-00:O/S Documentation Set - Italian:O/S Documentation Set - Kanji:Standard Mouse:Deluxe Mouse:Keyboard Wrist Rest:CD-R Mini Discs
01-AUG-00:31-AUG-00:Music CD-R:CD-RW, High Speed, Pack of 10:CD-RW, High Speed Pack of 5:CD-R, Professional Grade, Pack of 10:OraMusic CD-R, Pack of 10
01-SEP-00:30-SEP-00:CD-R with Jewel Cases, pACK OF 12:DVD-R Disc with Jewel Case, 4.7 GB:DVD-RAM Jewel Case, Double-Sided, 9.4G:DVD-R Discs, 4.7GB, Pack of 5:DVD-R Discs, 4.7GB, Pack of 5
01-OCT-00:31-OCT-00:DVD-RW Discs, 4.7GB, Pack of 3:3 1/2" Bulk diskettes, Box of 50:3 1/2" Bulk diskettes, Box of 100:Model CD13272 Tricolor Ink Cartridge:Model SM26273 Black Ink Cartridge
01-NOV-00:30-NOV-00:Model NM500X High Yield Toner Cartridge:Model A3827H Black Image Cartridge:Model K3822L Cordless Phone Battery:Model C9827B Cordless Phone Battery:Model K8822S Cordless Phone Battery
01-DEC-00:31-DEC-00:Model C93822D Wireless Phone Battery:S27273M Extended Use w/l Phone Batt.:64MB Memory Card:128MB Memory Card:256MB Memory Card
44 changes: 44 additions & 0 deletions examples/ch23_ex4.tcl
@@ -0,0 +1,44 @@
#!/usr/local/bin/tclsh8.4
package require Oratcl
####UPDATE THE CONNECT STRING BELOW###
set connect sh/sh@rac
set lda [oralogon $connect]
set curn1 [oraopen $lda]
set sql1 "SELECT time_id, channel_id, prod_id, ROUND (SUM(amount_sold)) AS TOTAL FROM SALES WHERE time_id BETWEEN TO_DATE(:t_id1) AND TO_DATE(:t_id2) AND prod_id IN (SELECT prod_id FROM products WHERE prod_name IN (:pname1,:pname2,:pname3,:pname4,:pname5)) GROUP BY ROLLUP (time_id, (channel_id, prod_id)) "
orasql $curn1 $sql1 -parseonly
set fd [ open /home/oracle/input1.txt r ]
set flbuff [read $fd]
close $fd
set filelist [split $flbuff "\n"]
unset flbuff
foreach line $filelist {
set params [ split [ regsub -all {(\ \ )} $line {} ] ":" ]
set startdate [ string trim [ lindex $params 0 ] ]
set enddate [ string trim [ lindex $params 1 ] ]
set pname1 [ string trim [ lindex $params 2] ]
set pname2 [ string trim [ lindex $params 3] ]
set pname3 [ string trim [ lindex $params 4 ] ]
set pname4 [ string trim [ lindex $params 5 ] ]
set pname5 [ string trim [ lindex $params 6 ] ]
set value [ time { orabindexec $curn1 :t_id1 $startdate :t_id2 $enddate :pname1 $pname1 :pname2 $pname2 :pname3 $pname3 :pname4 $pname4 :pname5 $pname5
set row [orafetch $curn1 -datavariable output ]
while { [ oramsg $curn1 ] == 0 } {
set row [orafetch $curn1 -datavariable output ] } } ]
regexp {([0-9]+)} $value all tim
lappend microsecs $tim
}
oraclose $curn1
oralogoff $lda
set max 0
foreach val $microsecs {
if { $val > $max } { set max $val }
}
puts "Maximum user response time was $max microseconds"
set sum 0
foreach val $microsecs {
set sum [ expr { $sum+$val } ]
}
puts "Total user response time was $sum microseconds"
set N [ expr { [ llength $microsecs ] + 1 } ]
set average [ expr { $sum/$N } ]
puts "Average response time was $average microseconds"
6 changes: 6 additions & 0 deletions examples/ch23_ex5.tcl
@@ -0,0 +1,6 @@
proc RandomNumber { min max } {
set maxFactor [expr [expr $max + 1] - $min]
set value [expr int([expr rand() * 300000])]
set value [expr [expr $value % $maxFactor] + $min]
return $value
}
4 changes: 4 additions & 0 deletions examples/ch23_ex6.tcl
@@ -0,0 +1,4 @@
set filelist [ list /home/oracle/input1.txt /home/oracle/input2.txt /home/oracle/input3.txt /home/oracle/input4.txt /home/oracle/input5.txt ]
set choice [ RandomNumber 0 [ expr $ll - 1 ] ]
set fc [ lindex $filelist $choice ]
set fd [ open $fc r ]
9 changes: 9 additions & 0 deletions examples/ch23_ex7.tcl
@@ -0,0 +1,9 @@
set mythread [thread::id]
set allthreads [split [thread::names]]
set totalvirtualusers [expr [llength $allthreads] - 1]
set myposition [expr $totalvirtualusers - [lsearch -exact $allthreads $mythread]]
switch $myposition {
1 { puts "I am the first virtual user, I'll be inserting" }
2 { puts "I am the second virtual user, I'll be deleting" }
default { puts "I am a default virtual user, I'll be selecting" }
}
5 changes: 5 additions & 0 deletions examples/ch23_ex8.tcl
@@ -0,0 +1,5 @@
set start [ clock seconds ]
...
set end [ clock seconds ]
set wall [ expr $end - $start ]
puts "Wall time elapsed was $start to $end = $wall seconds"
4 changes: 4 additions & 0 deletions examples/ch23_ex9.tcl
@@ -0,0 +1,4 @@
if {[ catch { ... } message] } {
puts $message
puts [ oramsg $curn1 all ]
}

0 comments on commit 4886241

Please sign in to comment.