Presentation is loading. Please wait.

Presentation is loading. Please wait.

McGraw-Hill/Irwin Copyright © 2005 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 10: Distributed Databases and the Internet All Powder.

Similar presentations


Presentation on theme: "McGraw-Hill/Irwin Copyright © 2005 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 10: Distributed Databases and the Internet All Powder."— Presentation transcript:

1 McGraw-Hill/Irwin Copyright © 2005 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 10: Distributed Databases and the Internet All Powder Board and Ski Designing & Building Business Applications Oracle 9i Jerry Post

2 2 All Powder LAN Offices/Managers Checkout Rental Desk Network Switch Server

3 3 Action If necessary, create a second database, preferably on a different machine Create a small Customer table and load it with four or five rows of data Return to your main database and create a database link to the target Run an SQL statement that retrieves data across the link

4 4 Create Target Database and Table Create a new database if necessary: Start/All Programs/Oracle-OraHome92/Configuration and Migration Tools/ Database Configuration Assistant Use Net Manager to add a hostname entry Log in and create a new user/schema or use the system schema Create a small table CREATE TABLE Customer ( CustomerID INTEGER, LastNameVARCHAR2(15), FirstNameVARCHAR2(15), Constraint pk_Customer Primary Key (CustomerID) ); INSERT INTO Customer (CustomerID, LastName, FirstName) Values (1,'Smith', 'Adam'); INSERT INTO Customer (CustomerID, LastName, FirstName) Values (2,'Keynes', 'John'); INSERT INTO Customer (CustomerID, LastName, FirstName) Values (3,'Samuelson', 'Paul'); INSERT INTO Customer (CustomerID, LastName, FirstName) Values (4,'Robinson', 'Joan'); Commit;

5 5 Link to Target Database CREATE DATABASE LINK NewYork CONNECT TO RemoteUser IDENTIFIED BY t1 USING 'dbhostname'; SELECT * FROM Customer@NewYork; Create a descriptive name for the link User account and password on the target database Database hostname in the network file Table name@link name

6 6 Database Replicas Master Site Materialized View (Replica) Replication Group Deployment Template Link Schedule Synchronize

7 7 Action Choose Tools/Replication/Create Replica Make a change to a customer name in the master database Add a new customer in the replica In the master database, choose Tools/Replication/Synchronize Now Verify that both databases now contain the same data

8 8 Create a Materialized View Replica 1.Start the Deployment Template 1.Set up Master Sites 2.Disconnect and log in as RepAdmin 3.Create a Master Group 4.Create the Template 5.Generate the script 2.Create Materialized View logs on the master site for each table 3.On the client, or build as PL/SQL to add to the script 1.Manually create a Materialized View Group creating a new Refresh Group matching name from template: CustomerTemplate 2.Select the Customer materialized view (or all) 3.Add the materialized view to the refresh group

9 9 Creating Replicas: Deployment Template-Master Site Add the main database Log in as SYSDBA Open Advanced Replication and follow menu options

10 10 Action Use the Enterprise Manager to open the master database and expand the replication section Start the Deployment Template Set up the Master Site Disconnect and log in as RepAdmin Create a Master Group Create the template Generate the script Create Materialized View logs On the client target run the script Manually create a Materialized View group Create the Materialized Views Add the views to the refresh group Refresh the group Test a query

11 11 Replica: Deployment: Master Group Objects tab Select Customer table

12 12 Template: Create Views Create template Select tables

13 13 Generate Template: Schema

14 14 Create Materialized View CREATE MATERIALIZED VIEW Powder.Customer FOR UPDATE AS SELECT * FROM Powder.Customer@host_database_link;

15 15 Client Side MV and Refresh Group Create refresh group Add materialized views Refresh

16 16 PL/SQL on Web Pages (0) Configure the Data Access Descriptor (DAD) (1) Create the basic html form to get the SaleIDGetSale.psp (2) Create the page to display the resultsListSales.psp (3) loadpsp -replace -user powder/ski1@PostDB GetSale.psp (4) loadpsp -replace -user powder/ski1@PostDB ListSales.psp (5) http://PostDB/pls/simpledad/Powder.GetSale Pages without JavaPages are stored as procedures within the database and use embedded PL/SQL to connect to the database Two page example to enter a SaleID and lookup the matching data

17 17 Action Configure a Data Access Descriptor Create two Web pages: GetSale and ListSales Load the pages into the database Open the first page and test the form

18 18 Configure DAD http://server Pick: Mod plsql Configuration Menu Modify the SimpleDAD, or create a new one Schema Name: Powder UserName: Powder Password: Connect String: PostDB Authentication Mode: Basic Leave the other defaults

19 19 GetSale.psp Form Page Get SaleID All Powder Board and Ski Shop Sales Enter a Sale ID value:

20 20 ListSales.psp Display Page List Sales Data Sales data for SaleID: Sale ID Sale Date CustomerID <% for item in (select * from sale where SaleID=l_SaleID order by SaleDate) loop %>

21 21 Load Pages Into Oracle (3) loadpsp -replace -user powder/ski1@PostDB GetSale.psp (4) loadpsp -replace -user powder/ski1@PostDB ListSales.psp Go to the command line (DOS) You must include the database name

22 22 Open the First Page in a Browser http://PostDB/pls/simpledad/powder.getsale The URL is very picky and must be complete (regardless of what the documentation says). And watch the dot! http://WebServer/pls/DADName/Schema.Procedure

23 23 Results The example is simple to highlight the steps. You can retrieve more rows. You can use a better format.

24 24 Action In SQL Plus, run the SELECT XMLElement command to create an XML file for some of the employee data Edit the resulting file to remove the extra title lines printed by SQL Add the tag and the starting and ending tag Open the file in Internet Explorer

25 25 Create XML File with SQL SET long 20000 SET pages 100 SPOOL D:\Students\AllPowder\Employee10.xml SELECT XMLElement("Employee", XMLElement("LastName", LastName), XMLElement("FirstName", FirstName)) FROM Employee WHERE rownum<10; SPOOL OFF Eliminate line and page breaks Send output to a file Limit data to 9 rows to keep the file smaller for now

26 26 XML File: Cleaned Up Staff Killy Jean-Claude …

27 27 XML File in Internet Explorer

28 McGraw-Hill/Irwin Copyright © 2005 by The McGraw-Hill Companies, Inc. All rights reserved. End of Chapter 10 Designing & Building Business Applications Oracle 9i Jerry Post


Download ppt "McGraw-Hill/Irwin Copyright © 2005 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 10: Distributed Databases and the Internet All Powder."

Similar presentations


Ads by Google