guide apex part 1

406
Oracle Application Express: Developing Web Applications Volume I • Activity Guide D56782GC20 Edition 2.0 November 2010 D69855

Upload: elena-monica-uta

Post on 17-Nov-2015

37 views

Category:

Documents


15 download

DESCRIPTION

Guide Apex Part 1

TRANSCRIPT

  • Oracle Application Express: Developing Web Applications

    Volume I Activity Guide

    D56782GC20

    Edition 2.0

    November 2010

    D69855

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved. Disclaimer This document contains proprietary information and is protected by copyright and other intellectual property laws. You may copy and print this document solely for your own use in an Oracle training course. The document may not be modified or altered in any way. Except where your use constitutes "fair use" under copyright law, you may not use, share, download, upload, copy, print, display, perform, reproduce, publish, license, post, transmit, or distribute this document in whole or in part without the express authorization of Oracle. The information contained in this document is subject to change without notice. If you find any problems in the document, please report them in writing to: Oracle University, 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not warranted to be error-free. Restricted Rights Notice If this documentation is delivered to the United States Government or anyone using the documentation on behalf of the United States Government, the following notice is applicable: U.S. GOVERNMENT RIGHTS The U.S. Governments rights to use, modify, reproduce, release, perform, display, or disclose these training materials are restricted by the terms of the applicable Oracle license agreement and/or the applicable U.S. Government contract. Trademark Notice Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.

    Authors Marcie Young, Salome Clement

    Technical Contributors and Reviewers Anthony Rayner, Bryan Roberts, Chaitanya Koratamaddi, Christina Cho, Christopher Wensley, Drue Baker, Ganesh Pitchaiah, Hailing Huang, Hilary Farrell, Iloon Ellen, Jason Straub, Jean-Paul Fillon, Joel Kallman, Linda Ross, Nancy Greenberg, Madhavi Siddireddy, Maria Billings, Matthew Gregory, Michael Hichwa, Patrick Wolf, Sharon Kennedy, Terri Jennings, Yi Lu, Wayne Abbott

    This book was published using: Oracle Tutor

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Oracle Application Express: Developing Web Applications - Table of Contents i

    Table of Contents

    Practices for Lesson 1: Course Overview .....................................................................................................1-1 Practices for Lesson 1 ....................................................................................................................................1-3

    Practices for Lesson 2: Introduction to Oracle Application Express ..........................................................2-1 Practices for Lesson 2 ....................................................................................................................................2-3 Practice 2-1: Using Oracle Application Express as a Workspace Administrator ............................................2-4 Practice 2-2: Using Oracle Application Express as a Developer ....................................................................2-5 Practice Solution 2-1: Using Oracle Application Express as a Workspace Administrator ..............................2-6 Practice Solution 2-2: Using Oracle Application as a Developer ....................................................................2-9

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop ......................................3-1 Practices for Lesson 3 ....................................................................................................................................3-3 Practice 3-1: Using Object Browser ...............................................................................................................3-4 Practice 3-2: Using SQL Commands, SQL Scripts, and Query Builder ..........................................................3-5 Practice 3-3: Using Utilities ............................................................................................................................3-6 Practice Solution 3-1: Using Object Browser .................................................................................................3-7 Practice Solution 3-2: Using SQL Commands, SQL Scripts, and Query Builder ............................................3-19 Practice Solution 3-3: Using Utilities ..............................................................................................................3-32

    Practices for Lesson 4: Building a Database Application ............................................................................4-1 Practices for Lesson 4 ....................................................................................................................................4-3 Practice 4-1: Creating an Application from a Spreadsheet .............................................................................4-4 Practice 4-2: Creating Applications from Scratch ...........................................................................................4-5 Practice Solution 4-1: Creating an Application from a Spreadsheet ...............................................................4-6 Practice Solution 4-2: Creating Applications from Scratch .............................................................................4-16

    Practices for Lesson 5: Creating Reports ......................................................................................................5-1 Practices for Lesson 5 ....................................................................................................................................5-3 Practice 5-1: Building and Manipulating an Interactive Report .......................................................................5-4 Practice 5-2: Customizing Your Interactive Report.........................................................................................5-5 Practice 5-3: Creating a SQL Report ..............................................................................................................5-6 Practice 5-4: Creating a Wizard Report ..........................................................................................................5-7 Practice Solution 5-1: Building and Manipulating an Interactive Report .........................................................5-8 Practice Solution 5-2: Customizing an Interactive Report ..............................................................................5-42 Practice Solution 5-3: Creating a SQL Report ................................................................................................5-52 Practice Solution 5-4: Creating a Wizard Report ............................................................................................5-60

    Practices for Lesson 6: Creating Forms ........................................................................................................6-1 Practices for Lesson 6 ....................................................................................................................................6-3 Practice 6-1: Creating a Form on a Table ......................................................................................................6-4 Practice 6-2: Creating a Master Detail Form ..................................................................................................6-5 Practice 6-3: Creating a Tabular Form ...........................................................................................................6-6 Practice Solution 6-1: Creating a Form on a Table ........................................................................................6-7 Practice Solution 6-2: Creating a Master Detail Form ....................................................................................6-20 Practice Solution 6-3: Creating a Tabular Form .............................................................................................6-36

    Practices for Lesson 7: Working with Pages and Regions ..........................................................................7-1 Practices for Lesson 7 ....................................................................................................................................7-3 Practice 7-1: Working with Pages and Regions .............................................................................................7-4 Practice Solution 7-1: Working with Pages and Regions ...............................................................................7-6

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Oracle Application Express: Developing Web Applications - Table of Contents ii

    Practices for Lesson 8: Understanding Session State and Debugging ......................................................8-1 Practices for Lesson 8 ....................................................................................................................................8-3 Practice 8-1: Understanding Session State ....................................................................................................8-4 Practice 8-2: Debugging Your Application ......................................................................................................8-5 Practice Solution 8-1: Understanding Session State ......................................................................................8-6 Practice Solution 8-2: Debugging Your Application ........................................................................................8-24

    Practices for Lesson 9: Adding Items and Buttons ......................................................................................9-1 Practices for Lesson 9 ....................................................................................................................................9-3 Practice 9-1: Adding Items and Buttons .........................................................................................................9-4 Practice 9-2: Manipulating Items ....................................................................................................................9-5 Practice 9-3: Create an Upload and Download Page .....................................................................................9-7 Practice Solution 9-1: Adding Items and Buttons ...........................................................................................9-8 Practice Solution 9-2: Manipulating Items ......................................................................................................9-27 Practice Solution 9-3: Create an Upload and Download Page .......................................................................9-51

    Practices for Lesson 10: Including Page Processing ...................................................................................10-1 Practices for Lesson 10 ..................................................................................................................................10-3 Practice 10-1: Creating and Manipulating Computations, Processes, and Validations ..................................10-4 Practice Solution 10-1: Creating and Manipulating Computations, Processes, and Validations ....................10-6

    Practices for Lesson 11: Using Application and Page Utilities....................................................................11-1 Practices for Lesson 11 ..................................................................................................................................11-3 Practice 11-1: Use the Advisor .......................................................................................................................11-4 Practice 11-2: Manage Your Attribute Dictionary ...........................................................................................11-5 Practice Solution 11-1: Using the Advisor ......................................................................................................11-6 Practice Solution 11-2: Manage Your Attribute Dictionary .............................................................................11-13

    Practices for Lesson 12: Adding Shared Components That Aid Navigation ..............................................12-1 Practices for Lesson 12 ..................................................................................................................................12-3 Practice 12-1: Creating Lists and List Regions ..............................................................................................12-4 Practice 12-2: Creating and Editing Standard Tabs .......................................................................................12-5 Practice 12-3: Managing Help Text in Your Application .................................................................................12-6 Practice 12-4: Adding Navigation Bar Entries ................................................................................................12-7 Practice 12-5: Adding Breadcrumbs and Tabs to an Existing Page ...............................................................12-8 Practice Solution 12-1: Creating Lists and List Regions .................................................................................12-9 Practice Solution 12-2: Creating and Editing Standard Tabs .........................................................................12-16 Practice Solution 12-3: Managing Help Text in Your Application ...................................................................12-22 Practice Solution 12-4: Adding Navigation Bar Entries ..................................................................................12-29 Practice Solution 12-5: Adding Breadcrumbs and Tabs to an Existing Page .................................................12-39

    Practices for Lesson 13: Displaying Dynamic Content ................................................................................13-1 Practices for Lesson 13 ..................................................................................................................................13-3 Practice 13-1: Using Dynamic Actions on Your Page ....................................................................................13-4 Practice 13-2: Importing and Using the Star Rating Plug-In ...........................................................................13-6 Practice 13-3: Creating and Modifying Flash Charts ......................................................................................13-7 Practice 13-4: Creating a Calendar ................................................................................................................13-8 Practice 13-5: Creating a Tree Whose Nodes Link to a Different Page .........................................................13-9 Practice Solution 13-1: Using Dynamic Actions on Your Page ......................................................................13-10 Practice Solution 13-2: Importing and Using the Star Rating Plug-In .............................................................13-35 Practice Solution 13-3: Creating and Modifying Flash Charts ........................................................................13-46

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Oracle Application Express: Developing Web Applications - Table of Contents iii

    Practice Solution 13-4: Adding a Calendar ....................................................................................................13-59 Practice Solution 13-5: Creating a Tree Whose Nodes Link to a Different Page ...........................................13-70

    Practices for Lesson 14: Working with Themes, Templates, and Files .......................................................14-1 Practices for Lesson 14 ..................................................................................................................................14-3 Practice 14-1: Working with Themes, Templates, and Files ..........................................................................14-4 Practice Solution 14-1: Working with Themes, Templates, and Files.............................................................14-6

    Practices for Lesson 15: Administering Oracle Application Express Workspaces ...................................15-1 Practices for Lesson 15 ..................................................................................................................................15-3 Practice 15-1: Administering Oracle Application Express Workspaces ..........................................................15-4 Practice Solution 15-1: Administering Oracle Application Express Workspaces ............................................15-5

    Practices for Lesson 16: Implementing Security ..........................................................................................16-1 Practices for Lesson 16 ..................................................................................................................................16-3 Practice 16-1: Creating an Authentication Scheme ........................................................................................16-4 Practice 16-2: Restricting Users by Using Access Control .............................................................................16-5 Practice 16-3: Enabling Session State Protection ..........................................................................................16-6 Practice Solution 16-1: Creating an Authentication Scheme ..........................................................................16-7 Practice Solution 16-2: Restricting Users by Using Access Control ...............................................................16-12 Practice Solution 16-3: Enabling Session State Protection ............................................................................16-29

    Practices for Lesson 17: Building a Websheet Application .........................................................................17-1 Practices for Lesson 17 ..................................................................................................................................17-3 Practice 17-1: Creating and Modifying a Websheet Application .....................................................................17-4 Practice 17-2: Adding and Manipulating a Data Grid and Report ...................................................................17-5 Practice 17-3: Adding and Manipulating Sections in a Page ..........................................................................17-6 Practice 17-4: Sharing Websheets Between Users ........................................................................................17-7 Practice Solution 17-1: Creating and Modifying a Websheet Application .......................................................17-8 Practice Solution 17-2: Adding and Manipulating a Data Grid and Report .....................................................17-20 Practice Solution 17-3: Adding and Manipulating Sections in a Page ............................................................17-43 Practice Solution 17-4: Sharing Websheets Between Users ..........................................................................17-56

    Practices for Lesson 18: Deploying Your Application ..................................................................................18-1 Practices for Lesson 18 ..................................................................................................................................18-3 Practice 18-1: Deploying Your Application .....................................................................................................18-4 Practice Solution 18-1: Deploying Your Application .......................................................................................18-5

    Practices for Lesson 19: Managing and Maintaining the Application Development Process ...................19-1 Practices for Lesson 19 ..................................................................................................................................19-3 Practice 19-1: Adding Features and Milestones to Your Development Project ..............................................19-4 Practice 19-2: Adding and Monitoring Feedback in Your Application .............................................................19-6 Practice Solution 19-1: Adding Milestones and Features to Your Development Project ................................19-7 Practice Solution 19-2: Adding and Monitoring Feedback in Your Application ...............................................19-23

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Oracle Application Express: Developing Web Applications - Table of Contents v

    Preface

    Profile Before you begin this course, you should be familiar with SQL and PL/SQL.

    How This Course Is Organized Oracle Application Express: Developing Web Applications is an instructor-led course featuring lectures and hands-on exercises. Online demonstrations and written practice sessions reinforce the concepts and skills introduced.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Oracle Application Express: Developing Web Applications - Table of Contents vi

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 1: Course Overview Chapter 1 - Page 1

    Practices for Lesson 1: Course Overview Chapter 1

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 1: Course Overview Chapter 1 - Page 2

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 1: Course Overview Chapter 1 - Page 3

    Practices for Lesson 1

    There are no practices for this Lesson.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 1: Course Overview Chapter 1 - Page 4

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 2: Introduction to Oracle Application Express Chapter 2 - Page 1

    Practices for Lesson 2: Introduction to Oracle Application Express Chapter 2

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 2: Introduction to Oracle Application Express Chapter 2 - Page 2

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 2: Introduction to Oracle Application Express Chapter 2 - Page 3

    Practices for Lesson 2

    Practices Overview There are two practices for this lesson. In these practices, you log in to Oracle Application Express and create the users that you will need for the rest of the practices in this course. You also run a sample application and install a packaged application. The packaged application creates an application definition and the database objects that you will need for this course.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 2: Introduction to Oracle Application Express Chapter 2 - Page 4

    Practice 2-1: Using Oracle Application Express as a Workspace Administrator

    Overview In this practice, you log in to the Oracle Application Express workspace and create a developer user.

    Assumptions N/A

    Tasks a. Log in to Oracle Application Express with the following details:

    Workspace: ora Username: ora_admin Password: ora

    b. Create a developer user with the following details: Username and Password: ora Email: [email protected]

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 2: Introduction to Oracle Application Express Chapter 2 - Page 5

    Practice 2-2: Using Oracle Application Express as a Developer

    Overview In this practice, you log in to Oracle Application Express as a Developer, run a sample application, and install a packaged application.

    Assumptions You have created the ora user from the previous practice.

    Tasks a. Login to Oracle Application with the following details:

    Workspace: ora Username: ora Password: ora

    b. Run the sample application.

    c. Install the packaged application and its supporting objects from the following location: /home/oracle/labs/oehr/oehr_object_app_installer.sql

    Note: This application will be used throughout the course.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 2: Introduction to Oracle Application Express Chapter 2 - Page 6

    Practice Solution 2-1: Using Oracle Application Express as a Workspace Administrator

    Overview In this practice solution, steps to log in to the Oracle Application Express workspace and create a developer user are provided.

    Tasks a. Log in to Oracle Application Express with the following details:

    Workspace: ora Username: ora_admin Password: ora 1) Enter the following URL in your browser address bar.

    http://:8080/apex

    2) In the Login page, enter ora for Workspace, ora_admin for Username, and ora for Password, and click Login.

    3) If you are prompted to change your password, enter the old and new passwords and click Apply Changes. (You can enter the current password as your new password.)

    4) Click Return.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 2: Introduction to Oracle Application Express Chapter 2 - Page 7

    5) You will be directed to log in again. Enter the new password and click Login.

    6) You have successfully logged in to Oracle Application Express application as an administrator user.

    b. Create a developer user with the following details: Username and Password: ora Email: [email protected]

    1) Click the down arrow in the Administration tab and select Manage Users and Groups.

    2) Click Create User.

    3) Enter ora for Username and [email protected] for Email Address.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 2: Introduction to Oracle Application Express Chapter 2 - Page 8

    4) Scroll down and verify the account privileges. Make sure that User is a workspace administrator is set to No and User is a developer is set to Yes.

    5) Scroll down and enter ora for Password and Confirm Password. Select No for Require Change Of Password On First Use.

    6) Scroll up to the top of the page and click Create User.

    7) Click Logout.

    You have successfully created a developer user by logging in to Oracle Application Express application as a workspace administrator.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 2: Introduction to Oracle Application Express Chapter 2 - Page 9

    Practice Solution 2-2: Using Oracle Application as a Developer

    Overview In this practice solution, the steps to log in to Oracle Application Express as a developer, run a sample application, and install a packaged application are provided.

    Tasks a. Log in to Oracle Application with the following details:

    Workspace: ora Username: ora Password: ora 1) Click Login. 2) Enter ora for Workspace, Username, and Password, and click Login.

    You have successfully logged in to Oracle APEX as a developer.

    b. Run the sample application.

    1) Click the Application Builder icon on the Oracle APEX homepage.

    2) Click the Sample Application icon.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 2: Introduction to Oracle Application Express Chapter 2 - Page 10

    3) Click the Run Application icon.

    4) Enter Demo for User Name, enter ora for Password ,and click Login.

    5) The Sample Application displays. Click the various tabs and try to understand what the application does.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 2: Introduction to Oracle Application Express Chapter 2 - Page 11

    6) Click the Home button in the bottom toolbar.

    You have successfully run the sample application.

    c. Install the packaged application and its supporting objects from the following location:

    /home/oracle/labs/oehr/oehr_object_app_installer.sql

    1) Navigate to the Application Builder page by clicking the Application Builder icon.

    2) Click the Import button.

    3) Click the Browse button.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 2: Introduction to Oracle Application Express Chapter 2 - Page 12

    4) Browse to the /home/oracle/labs/oehr folder, select the

    oehr_object_app_installer.sql script file, and click Open.

    5) Click Next to import the file.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 2: Introduction to Oracle Application Express Chapter 2 - Page 13

    6) You have successfully imported the file. To install the application, click Next.

    7) Select ora for Parsing Schema and click Install.

    8) To install the supporting objects for the application, ensure that Install Supporting

    Objects is Yes and click Next.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 2: Introduction to Oracle Application Express Chapter 2 - Page 14

    9) Click Install to confirm the installation of supporting objects.

    10) Click Install Summary.

    11) Review the Install Summary.

    You have successfully installed a packaged application.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 1

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 2

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 3

    Practices for Lesson 3

    Practices Overview There are three practices for this lesson. In these practices, you use the components of SQL Workshop to create and modify tables, upload and run scripts, build and save queries, and load and unload data. Hints in the form of SQL queries have been provided in case you are not familiar with writing SQL queries.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 4

    Practice 3-1: Using Object Browser

    Overview In this practice, you use the Object Browser to view, create, and modify tables.

    Assumptions N/A

    Tasks a. Create a table called OEHR_AUDITS with the following details.

    Column Name Data Type Other Details

    CUSTOMER_ID (PK) NUMBER Not populated

    CREATED_BY VARCHAR2 Scale 40

    CREATED_ON DATE N/A

    b. Review the data in the OEHR_ORDERS table.

    c. Create a lookup table for the OEHR_ORDERS table by using the ORDER_MODE column. Follow the following naming convention:

    Table name: OEHR_ORDER_MODE_LOOKUP Sequence name: OEHR_ORDER_MODE_LOOKUP_SEQ

    What do you think will happen to the data in both tables after the lookup table has been created?

    d. Display the data from the OEHR_COUNTRIES table and save the data in a spreadsheet.

    e. Change the data type for the JOB_TITLE column in the OEHR_JOBS table to char and the length to 300.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 5

    Practice 3-2: Using SQL Commands, SQL Scripts, and Query Builder

    Overview In this practice, you use SQL Commands, SQL Scripts, and Query Builder to upload, save, and run queries.

    Assumptions You have performed the previous practice.

    Tasks a. Using SQL Commands, update the ORDER_DATE column in the OEHR_ORDERS table

    by running the following query. UPDATE oehr_orders

    SET order_date = order_date + 2290

    b. Upload the CreateTerritories.sql script file from the

    /home/oracle/labs/scripts folder and name it Create Territory Table. Run the script and confirm that it ran successfully.

    c. Upload the get_sal.sql script file from the /home/oracle/labs/scripts folder

    and name it Get Salary. Run the script and correct errors, if any.

    d. Use the get_sal procedure, created in the previous task, and execute a query that displays the last name, employee ID, and salary for employees. Also include a proposed salary, which should be 40% more than the current salary.

    Hint: SELECT last_name, employee_id, salary CURRENT SALARY,

    get_sal(employee_id, 1.4) PROPOSED SALARY

    FROM oehr_employees;

    e. Using Query Builder, create and save a query to retrieve the department ID, name,

    city, state, and the country name for each department.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 6

    Practice 3-3: Using Utilities

    Overview In this practice, you use SQL Workshop Utilities to load/unload data and generate DDL.

    Assumptions You have performed the previous practice.

    Tasks a. Load data from a flat file to a new database table called OEHR_STATES. The file is

    available in the /home/oracle/labs/files folder. The data in the file is stored as comma-separated values (CSV) and the first row in the file contains the column names. Name the table columns STATE_ID and STATE_NAME. Accept the option to create a new primary key and sequence. View the created table in the Object Browser.

    b. Unload data from the OEHR_ORDERS table to a CSV file. Ensure that the table column names are also included in the file.

    c. Unload data from the OEHR_JOBS table to an XML document adhering to the canonical

    XML specification.

    d. Generate a DDL script file for the STATES table and sequence. Name the file as states.sql. Download and save the file to the /home/oracle/labs folder.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 7

    Practice Solution 3-1: Using Object Browser

    Overview In this practice solution, the steps to view, create, and modify tables by using the Object Browser are provided.

    Tasks a. Create a table called OEHR_AUDITS with the following details.

    Column Name Data Type Other Details

    CUSTOMER_ID (PK) NUMBER Not populated

    CREATED_BY VARCHAR2 Scale 40

    CREATED_ON DATE N/A

    1) Navigate to the Object Browser page by selecting Object Browser from the SQL

    Workshop tab menu.

    2) Click the down arrow in the Create button and select Table.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 8

    3) A Create Table wizard opens. Enter OEHR_AUDITS for Table Name and then fill out the columns by using the following details. Then click Next.

    Column Name Data Type Other Details CUSTOMER_ID (PK) NUMBER Not populated

    CREATED_BY VARCHAR2 Scale 40

    CREATED_ON DATE N/A

    4) Select Not populated for Primary Key. Select CUSTOMER_ID(NUMBER) from the

    drop-down list for Primary Key and click Next.

    5) You do not want to create a foreign key. Click Next.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 9

    6) You do not want to create constraints. Click Next.

    7) Click Create to create the table.

    8) The OEHR_AUDITS table is created and displayed in the Object Browser page.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 10

    You have successfully created a table.

    b. Review the data in the OEHR_ORDERS table.

    1) Select OEHR_ORDERS from the Object Selection pane of the Object Browser page.

    2) OEHR_ORDERS table is displayed in the detail pane. Select the Data tab.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 11

    3) Review the columns and the data they hold. Notice that the ORDER_MODE column

    is a good candidate for a lookup table.

    You have identified that a lookup table based on the ORDER_MODE column can be created for the OEHR_ORDERS table.

    c. Create a lookup table for the OEHR_ORDERS table by using the ORDER_MODE column.

    Follow the following naming convention: Table name: OEHR_ORDER_MODE_LOOKUP Sequence name: OEHR_ORDER_MODE_LOOKUP_SEQ

    What do you think will happen to the data in both the tables after the lookup table has been created? 1) Select the Table tab for the OEHR_ORDERS table.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 12

    2) Click the Create Lookup Table button.

    3) Select ORDER_MODE-varchar2 for Column and click Next.

    4) Enter OEHR_ORDER_MODE_LOOKUP for New Table Name and

    OEHR_ORDER_MODE_LOOKUP_SEQ for New Sequence and click Next.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 13

    5) Review the details and click Finish.

    6) To view the data in the lookup table, click the Data tab.

    7) View the columns and data in the new lookup table. Notice that the data from the OEHR_ORDERS table has been added here and a new primary key column inserted.

    8) To view the data in the OEHR_ORDERS table, select OEHR_ORDER from the Object

    Selection pane.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 14

    9) Note that ORDER_MODE column has been replaced with an ORDER_MODE_ID column.

    You have successfully created a lookup table.

    d. Display the data from the OEHR_COUNTRIES table and save the data in a spreadsheet.

    1) Select the OEHR_COUNTRIES table.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 15

    2) Scroll down to the bottom and click the Download link.

    3) Make sure that Open with the openoffice application is selected and click OK to save the file.

    4) Open Office will open. Click OK to import the text.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 16

    5) The data is displayed.

    e. Change the data type for the JOB_TITLE column in the OEHR_JOBS table to char and the length to 300. 1) Select the OEHR_JOBS table.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 17

    2) Click the Table tab.

    3) Click Modify Column.

    4) Select JOB_TITLE(VARCHAR2) for Column.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 18

    5) Select CHAR for Datatype, enter 300 for Length, and click Next.

    6) Click Finish.

    7) Review the change in the table.

    You have successfully modified a table.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 19

    Practice Solution 3-2: Using SQL Commands, SQL Scripts, and Query Builder

    Overview In this practice solution, the steps to upload, save, and run queries by using SQL Commands, SQL Scripts, and Query Builder are provided.

    Tasks a. Using SQL Commands, update the ORDER_DATE column in the OEHR_ORDERS table

    by running the following query. UPDATE oehr_orders

    SET order_date = order_date + 2290

    1) Select SQL Commands from the SQL Workshop tab menu.

    2) Enter the following command and click Run. UPDATE oehr_orders

    SET order_date = order_date + 2290

    3) View the output in the Results tab.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 20

    b. Upload the CreateTerritories.sql script file from the /home/oracle/labs/scripts folder and name it Create Territory Table. Run the script and confirm that it ran successfully. 1) Select SQL Scripts from the SQL Workshop tab menu.

    2) Click the Upload button.

    3) Click Browse and locate the file to upload.

    4) Select the /home/oracle/labs/scripts/CreateTerritories.sql and

    click Open.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 21

    5) Click Upload.

    6) The file was successfully loaded into SQL Scripts. Click the Run icon to run the script.

    7) Click Run Now.

    8) Click View Results.

    9) The script ran without errors.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 22

    You have successfully uploaded and run a script file.

    c. Upload the get_sal.sql script file from the /home/oracle/labs/scripts folder and name it Get Salary. Run the script and correct errors, if any. 1) Click the SQL Scripts breadcrumb.

    2) Click the Upload button.

    3) Click Browse and locate the file to upload.

    4) Select /home/oracle/labs/scripts/get_sal.sql and click Open.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 23

    5) Click Upload.

    6) Run the script by clicking the Run icon.

    7) Click Run Now.

    8) Click View Results.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 24

    9) Notice that the script has an error. Select the SQL Scripts breadcrumb.

    10) Select the 1 link for the get_sal.sql script.

    11) Select the get_sal.sql link.

    12) Notice that the statement in line 6 is missing a semicolon at the end. Correct the

    code and click Run.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 25

    13) Click Run Now.

    14) Click View Results.

    15) The script ran without errors this time.

    You have successfully uploaded, edited, and run a script file.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 26

    d. Use the get_sal procedure, created in the previous task, and execute a query that displays the last name, employee ID, and salary for employees. Also include a proposed salary, which should be 40% more than the current salary.

    Hint: SELECT last_name, employee_id, salary CURRENT SALARY,

    get_sal(employee_id, 1.4) PROPOSED SALARY

    FROM oehr_employees;

    1) Select SQL Commands from the SQL Workshop menu.

    2) Enter the following query and click Run. SELECT last_name, employee_id, salary CURRENT SALARY,

    Get_sal(employee_id, 1.4) PROPOSED SALARY

    FROM oehr_employees;

    3) View the output in the Results tab.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 27

    You successfully ran a SQL command that used the get_sal function you created in the previous task.

    e. Using Query Builder, create and save a query to retrieve the department ID, name, city, state, and the country name for each department. 1) Select Query Builder from the SQL Workshop tab menu.

    2) From the Object Selection pane, select the OEHR_DEPARTMENTS,

    OEHR_LOCATIONS, OEHR_COUNTRIES tables. They will appear in the Display pane.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 28

    3) Select the columns that you want to retrieve. Namely, DEPARTMENT_ID and

    DEPARTMENT_NAME from the OEHR_DEPARTMENTS table. CITY and STATE_PROVINCE from the OEHR_LOCATIONS table. And, COUNTRY_NAME from the COUNTRIES table.

    4) Now you want to join these tables. To join the OEHR_DEPARTMENTS and

    OEHR_LOCATION tables, select the join column for the LOCATION_ID column in the OEHR_DEPARTMENTS table and then click the join column for the LOCATION_ID column in the OEHR_LOCATIONS table.

    5) Similarly, join the OEHR_LOCATIONS and OEHR_COUNTRIES table on the

    COUNTRY_ID column.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 29

    6) Select the following columns and click the Run button.

    OEHR_DEPARTMENTS.DEPARTMENT_ID

    OEHR_DEPARTMENTS.DEPARTMENT_NAME

    OEHR_LOCATIONS.CITY

    OEHR_LOCATIONS.STATE_PROVINCE

    OEHR_COUNTRIES.COUNTRY_NAME

    7) The output is displayed in the Results tab of the Output pane.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 30

    8) To save the query, click the Save button.

    9) Enter a name for the query and click Save.

    10) The query is listed in the Saved SQL tab of the Output pane.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 31

    You have successfully created and saved a query by using Query Builder.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 32

    Practice Solution 3-3: Using Utilities

    Overview In this practice solution, the steps to load/unload data and generate DDL by using SQL Workshop Utilities are provided.

    Tasks a. Load data from a flat file to a new database table called OEHR_STATES. The file is

    available in the /home/oracle/labs/file folder. The data in the file is stored as comma-separated values (CSV) and the first row in the file contains the column names. Name the table columns STATE_ID and STATE_NAME. Accept the option to create a new primary key and sequence. View the created table in the Object Browser. 1) Select Data Workshop from the SQL Workshop tab menu.

    2) From the Data Load pane, click Text Data.

    3) Ensure that New table is selected for Load To and Upload file for Load From and click Next.

    4) Click Browse.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 33

    5) Select the /home/oracle/labs/files/states.txt file and click Open.

    6) Click Next.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 34

    7) Enter OEHR_STATES for Table Name. Change the first column name to STATE_ID and click Next.

    8) Select Use an existing column for Primary Key From and make sure that

    STATE_ID(VARCHAR2) is selected for the Primary Key and click Load Data.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 35

    9) To view the created table, click the SQL Workshop breadcrumb.

    10) Click Object Browser.

    11) From the Object Selection pane, locate and click the OEHR_STATES table.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 36

    12) View the created table.

    You have successfully loaded a table stored in a text file to the Oracle database.

    b. Unload data from the OEHR_ORDERS table to a CSV file. Ensure that the table column names are also included in the file. 1) Select Data Workshop from the SQL Workshop tab menu.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 37

    2) From the Data Unload pane, select to Text.

    3) Ensure that your schema is selected and click Next.

    4) Select the OEHR_ORDERS table and click Next.

    5) Select all the columns and click Next.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 38

    6) Click the Include Column Names check box and click Unload Data.

    7) Select Save File and click OK. Your file should be saved to the Desktop.

    Note: If you select the Open with option, you need to associate gedit. To do this, select Other from the drop-down list and navigate to /usr/bin/gedit.

    8) If you open the file (use gedit), it will look like the following:

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 39

    You have successfully unloaded table data to a text file and saved it in your local file system.

    c. Unload data from the OEHR_JOBS table to an XML document adhering to the canonical XML specification. 1) Select Data Workshop from the SQL Workshop tab menu.

    2) From the Data Unload pane, select to XML.

    3) Select your schema and click Next.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 40

    4) Select the OEHR_JOBS table and click Next.

    5) Select all the columns and click Unload Data.

    6) The XML is displayed.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 41

    You have successfully unloaded table data as an XML file.

    d. Generate a DDL script file for the STATES table and sequence. Name the file as states.sql. Download and save the file to the /home/oracle/labs folder. 1) Select Utilities from the SQL Workshop tab menu.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 42

    2) Click Generate DDL.

    3) Click Create Script.

    4) Select your schema and click Next.

    5) Select Save As Script File for output. Check the Table and Sequence object

    types and click Next.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 43

    6) Locate and check the OEHR_STATES_SEQ and OEHR_STATES and click Generate DDL.

    7) Enter states.sql for Script Name and click Create Script.

    8) The DDL script has been generated. Select the Edit icon in front of the states.sql

    script.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 3: Interacting with the Database by Using SQL Workshop Chapter 3 - Page 44

    9) The DDL is displayed.

    You have successfully generated DDL.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 1

    Practices for Lesson 4: Building a Database Application Chapter 4

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 2

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 3

    Practices for Lesson 4

    Practices Overview There are two practices for this lesson. In these practices, you create an application from a spreadsheet, and then you create two applications from scratch.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 4

    Practice 4-1: Creating an Application from a Spreadsheet

    Overview In this practice, you create an application from a spreadsheet and review the results.

    Assumptions You have performed the previous practices or imported LAB03_SOLN.SQL.

    Tasks a. Create an application from a spreadsheet named Tasks that is based on the

    tasks.txt file that is located in the /home/oracle/labs/scripts folder. The file has tab-delimited information, and the first row contains the column names. Use Theme 1.

    b. Manipulate the data in the Tasks application by performing the following steps:

    Steps Change

    1. Sort the tasks by start date.

    2. Edit the first record to change the status to closed.

    3. Add a record to the application with the following details: Project Name: Email Integration Task Name: Plan rollout schedule Start Date: Todays date End Date: Todays date plus Two years Status: open Assigned to: 4

    4. Display all the records that have rollout in the Task Name field.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 5

    Practice 4-2: Creating Applications from Scratch

    Overview In this practice, you create two applications from scratch and review the results.

    Assumptions You have performed the previous practices or imported LAB03_SOLN.

    Tasks a. Create an application called Customers Application that has a Report and Form page

    on the DEMO_CUSTOMERS table.

    b. Create an application called Order Management that has three blank pages for Home, Customers, and Products. It should have one-level tabs, use the application date format DD-MON-YYYY, and use Theme 20.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 6

    Practice Solution 4-1: Creating an Application from a Spreadsheet

    Overview In this practice solution, the steps to create an application from a spreadsheet are provided.

    Tasks a. Create an Application from a spreadsheet named Tasks that is based on the

    tasks.txt file that is located in the /home/oracle/labs/scripts folder. The file has tab-delimited information, and the first row contains the column names. Use Theme 1. 1) Navigate to Application Builder > Database Applications.

    2) On the Application Builder home page, click Create.

    3) Select Database Application and click Next.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 7

    4) Select the From Spreadsheet option and click Next.

    5) Select the Upload file, comma separated (*.csv) or tab delimited option and

    click Next.

    6) Click the Browse button or select the Text File field and select the tasks.txt file

    from the /home/oracle/labs/scripts folder on your machine. 7) To specify that the data is tab delimited, in the Separator field, enter \t. 8) Ensure that the First row contains column names check box is selected, and

    click Next.

    9) For Table Name, enter Task. Note that you can see all the data sorted as rows

    and columns. Click Next.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 8

    10) For Plural Name, enter Tasks and click Next.

    11) Ensure that Application Name is TASKS, Create Mode is Read and Write, and

    Report Implementation is Interactive. Click Next.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 9

    12) Select Theme 1 and click Next.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 10

    13) Click Create. Your application is created.

    14) To view the application, click Run Application.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 11

    15) Enter a username and password to log in to the application. For username and

    password, use ORA and ORA, respectively (where n is the number that you are assigned). Click Login. The home page of the TASKS application is displayed.

    16) The report for the Tasks application is shown. Observe that the default type when

    creating an application is an interactive report.

    b. Manipulate the data in the Tasks application by performing the following steps:

    Steps Change

    1. Sort the tasks by start date.

    2. Edit the first record to change the status to open.

    3. Add a record to the application with the following details: Project Name: Email Integration

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 12

    Steps Change Task Name: Plan rollout schedule Start Date: Todays date End Date: Todays date plus Two years Status: open Assigned to: 4

    4. Display all the records that have rollout in the Task Name field.

    1) To sort the tasks based on their start date, click the Start Date column heading

    and select Sort Ascending.

    2) Click the Start Date column again and select Sort Descending. The tasks are

    now displayed based on the descending order of start dates.

    3) To edit a record, click the edit ( ) icon for a row.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 13

    4) Change the value of Status to closed and click Apply Changes.

    5) To add a record, click the Create button.

    6) Enter the following details and click Create: Project Name: Email Integration Task Name: Plan rollout schedule Start Date: Todays date End Date: Todays date plus two years Status: open Assigned to: 4

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 14

    7) To return to the report, click View Report.

    8) To search for tasks that have rollout in the Task Name field, in the text area of the Search Bar, enter rollout. Click Go.

    9) Note that a filter is created to search by using the keyword rollout. You now see the task that you just added. Click Remove Filter (the X icon in red next, to the filter) to return to the home page.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 15

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 16

    Practice Solution 4-2: Creating Applications from Scratch

    Overview In this practice, you create two applications from scratch.

    Tasks a. Create an application called Customers Application that has a Report and Form page

    on the DEMO_CUSTOMERS table.

    1) Navigate to the Application Builder home page and click Create.

    2) Select Database and click Next.

    3) Select From Scratch and click Next.

    4) Enter Customer Application and click Next.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 17

    5) In the Add Page region, for Page Type, select Report and Form. 6) From the Table Name pop-up list, select DEMO_CUSTOMERS. Ensure that

    Interactive is selected for the Implementation field. Click Add Page.

    7) You can accept all the defaults and click Create.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 18

    8) Note that by default One Level of Tabs, Application Express Authentication, and Theme 1 are selected. To confirm, click Create.

    9) On the Customers Application home page, click the Run Application icon.

    10) Log in to the application with your ORA username and password and click

    Login.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 19

    11) The Demo Customers interactive report page is displayed. Click the Edit icon next

    to one of the customers.

    12) The Demo Customers form page is displayed. Change one of the values in the

    form and click Apply Changes.

    b. Create an application called Order Management that has three blank pages for Home, Customers, and Products. It should have one-level tabs, use the application date format DD-MON-YYYY, and use Theme 20. 1) Navigate to the Application Builder home page and click Create.

    2) Select Database for Application Type and click Next.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 20

    3) Select From Scratch and click Next.

    4) Enter Order Management for Name and click Next.

    5) Enter Home for Page Name and click Add Page.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 21

    6) The Home page is now in the list. Enter Customers for Page Name and click Add

    Page.

    7) The Customers page is in the list. Enter Products for Page Name and click Add

    Page.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 22

    8) All the pages have been created. Click Next.

    9) Accept the default and click Next.

    10) Accept the default and click Next.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 23

    11) Accept the default authentication scheme, Language, and select the Date Format

    selector icon.

    12) Select the 12-JAN-2004 date format link.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 24

    13) Click Next.

    14) Scroll down the page and select Theme 20. Then scroll up the page and click

    Next.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 25

    15) Click Create to create the application.

    16) Click Run Application.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 4: Building a Database Application Chapter 4 - Page 26

    17) Enter ora for Username and Password and click Login.

    18) The Home page is displayed. Note that there is a tab for each page that you

    created (for Customers and Products). Later in the course, you will add components to each of these pages.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 1

    Practices for Lesson 5: Creating Reports Chapter 5

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 2

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 3

    Practices for Lesson 5

    Practices Overview There are four practices for this lesson. In these practices, you build and manipulate an interactive report, customize an interactive report, and create a SQL report and a wizard report.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 4

    Practice 5-1: Building and Manipulating an Interactive Report

    Overview In this practice, you create and manipulate two interactive reports.

    Assumptions You have performed the previous practices or imported both LAB03_SOLN.SQL and LAB04_ORDER_MGMT_SOLN.SQL packaged applications.

    Tasks a. Create an interactive report region on the Customers page called Customer Report that

    displays all the columns from the OEHR_CUSTOMERS table. Perform the following customizations to the report: Create a filter on the city of Philadelphia. Create a highlight where Credit Limit is greater than 2500. Display only the customer name, address, and credit limit. Display only five rows to see how pagination works. Delete the filter that you created previously. Display the rows in ascending order by state. Create a Group By report to display the number of customers in a particular

    province or state. Save the report as a private report called My Report. Reset the primary report to its original state. View a single row view.

    b. Create an interactive report to display details (employee_id, first_name,

    last_name, manager_id, commission_pct), from the OEHR_EMPLOYEES table about who earns a commission. You must make the following customizations to the report: Management proposes to increase the commission to employees whose existing

    commission percentage is less than or equal to 0.15. Create a computed column to display the new commission. The new commission scheme includes: Employees with commission percentage of 0.1 will get an additional

    commission of 0.1. Employees with commission percentage of 0.15 will get an additional

    commission of 0.05. Create a control break on Manager ID. Display the maximum commission earned by employees under each manager. Download the HTML report. Save all the customizations that you have made to this report so that it will be

    available to other managers but is not the default report (not just you).

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 5

    Practice 5-2: Customizing Your Interactive Report

    Overview In this practice, you customize the interactive report that you created in the previous practice.

    Assumptions You have performed the previous practices or imported both LAB03_SOLN.SQL and LAB051_ORDER_MGMT_SOLN.SQL packaged applications.

    Tasks a. As a developer, you can change the way that the interactive report is rendered for all

    users. In this practice, you make the following customizations to the Commissions Report: Hide the EMPLOYEE_ID and change the MANAGER_ID to be the FIRST_NAME

    and LAST_NAME of the manager. Remove the Highlight option from the Actions menu. Add XLS and PDF download formats. Remove the Single Row View icon for each row in the report.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 6

    Practice 5-3: Creating a SQL Report

    Overview In this practice, you create a report by using the SQL Report Wizard.

    Assumptions You have performed the previous practices or imported both LAB03_SOLN.SQL and LAB052_ORDER_MGMT_SOLN.SQL packaged applications.

    Tasks a. Create a new page with a SQL report named Top Tier Salary in the Order

    Management application. The report should display the last name, email, and salary of employees who earn between $5,000 and $12,000. The report should contain a search bar.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 7

    Practice 5-4: Creating a Wizard Report

    Overview In this practice, you create a wizard report and edit the attributes of the report. You modify the column names and modify the query definition of the report and specify conditions for the query.

    Assumptions You have performed the previous practices or imported both LAB03_SOLN.SQL and LAB053_ORDER_MGMT_SOLN.SQL packaged applications.

    Tasks a. In the Order Management application, create a wizard report on a new page. Name it

    Customer Address List. The report displays the address information of your customers, such as the first and last names, address, city and state. Then run the report.

    b. Modify the Customer Address List report with the following requirements: Change the report headings for CUST_FIRST_NAME and CUST_LAST_NAME to

    First Name and Last Name respectively. Change the Pagination to Row Ranges X to Y of Z (with pagination). Review the query definition and add the OEHR_COUNTRIES.COUNTRY_NAME

    column to the report. Note: You will need to create a join.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 8

    Practice Solution 5-1: Building and Manipulating an Interactive Report

    Overview In this practice, you create and manipulate two interactive reports.

    Tasks a. Create an interactive report region on the Customers page called Customer Report that

    displays all the columns from the OEHR_CUSTOMERS table. Perform the following customizations to the report: Create a filter on the city of Philadelphia. Create a highlight where Credit Limit is greater than 2500. Display only the customer name, address, and credit limit. Display only five rows to see how pagination works. Delete the filter that you created previously. Display the rows in ascending order by state. Create a Group By report to display the number of customers in a particular

    province or state. Save the report as a private report called My Report. Reset the primary report to its original state. View a single row view. 1) Navigate to the Order Management Application Home Page and select the

    Customers page.

    2) The first time that you select a page, a help window appears that describes how to

    use the tree view. Click OK.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 9

    3) You want to create an interactive report on this page. Click Create and select

    Region on this page. Alternatively, you could right-click Regions and select Create.

    4) Select Report and click Next.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 10

    5) Select Interactive Report and click Next.

    6) Enter Customer Report for Title and click Next:

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 11

    7) You must use Query Builder or enter a query. Click Query Builder.

    8) Select OEHR_CUSTOMERS in the left navigator.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 12

    9) You want to select all the columns in this table. Click the Table Actions icon in the

    upper-left corner.

    10) Select the Check All check box and then close the window.

    11) All the columns are selected. Click Return.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 13

    12) The SQL query is displayed. You want to be able to view a single row view. Select

    Yes for Link to Single Row View and click Create Region.

    13) Your report was created. Click Run.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 14

    14) If you receive the login window, enter ora for username and password and

    click Login.

    15) Your interactive report is displayed.

    16) You want to show only the records for a particular city. Select City from the

    Column Selector. Note that if you do not select a column, the search criteria you enter in the next step will search all columns.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 15

    17) Enter Phil in the search field and click Go. Note that the % wildcard is implied and

    is not entered.

    18) A filter is applied and only the records that meet the search criteria are displayed.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 16

    19) You want to highlight only customers whose credit limit is greater than 2500. Click

    Actions and select Format > Highlight.

    20) Enter Good Credit Rating for Name, select [yellow] for background color, select

    Credit Limit for Column, > for Operator, and enter 2500 for Expression. Then click Apply.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 17

    21) The records that meet the criteria are displayed.

    22) You do not want some of the columns to appear on the report. Click Actions and

    select Select Columns.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 18

    23) Shift + select the following columns and click Remove to move them to the Do Not

    Display area. Note that you will still be able to perform other actions against these columns even though they are not displayed in the report. Customer Id

    Postal Code

    Country Id

    Phone Number

    Nls Language

    Nls Territory

    Cust Email

    Account Mgr Id

    24) Click Apply.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 19

    25) Only the columns that you selected appear in the report.

    26) You want to delete the filter that you created earlier. Click the Remove Filter icon

    for the City contains Phil filter.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 20

    27) You want to sort by State Province. Select the Column Header for State Province

    and click the Sort Ascending icon.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 21

    28) The records are sorted by City in ascending order. You want to change the number of rows that is displayed in the report. Click Actions.

    29) Select Rows Per Page and select 5. Note that the default value is 15.

    30) Note that only five rows are displayed and the pagination is automatically specified

    and you can click the icon to move to the next page.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 22

    31) To create a Group By report, click Actions and select Format > Group By.

    32) You want to show a list of states and how many customers are contained in that

    state. Select State Province for Group By Column, select Count for Function, select Customer Id for Column, and enter Number of Customers for the Label. Then click Apply.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 23

    33) Your Group by Report is displayed. Because the report does not have very many

    rows, you want to show them all. Click Actions and select Rows Per Page and select All.

    34) The State Provinces list and the number of customers per state is displayed. To

    return to the detail report, click the View Report icon.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 24

    35) You want to save this report as a private report that is available only to you. Click

    Actions and select Save Report.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 25

    36) Enter My Report for Name and click Apply.

    37) The report is saved. Select the Report drop-down list to see the list of reports.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 26

    38) Select the Primary Report.

    39) To return to the default settings, click Actions and select Reset.

    40) Click Apply.

    41) You see the original report without customizations.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 27

    42) You can view a row at a time. Click a Single Row View icon for one of the rows.

    43) One row is displayed. You can click the > or < icons to scroll to the next or

    previous row. You have completed this interactive report. Click the Application link at the bottom of the page.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 28

    b. Create an interactive report on a new page to display details of all employees (employee_id, first_name, last_name, manager_id, commission_pct) from the OEHR_EMPLOYEES table who earn a commission. After creating the report, make the following customizations to the report. Management proposes to increase the commission to employees whose existing

    commission percentage is less than or equal to 0.15. Create a computed column to display the new commission. The new commission scheme includes: Employees with commission percentage of 0.1 will get an additional

    commission of 0.1. Employees with commission percentage of 0.15 will get an additional

    commission of 0.05. Create a control break on Manager ID. Display the maximum commission earned by employees under each manager. Download the HTML report. Save all the customizations that you have made to this report so that it will be

    available to other managers but is not the default report (not just you).

    1) To use the print services functionality, BI Publisher must be running. To start BI publisher, open a terminal and enter the following commands. You can also use the /home/oracle/labs/scripts/bipub.txt file. /u01/app/oracle/OraHome_1/oc4j_bi/bin/oc4j -start

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 29

    2) Navigate to the Order Management application page. Click Create Page.

    3) Select Report and click Next.

    4) Select Interactive Report and click Next.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 30

    5) Enter Commission Report for both Page Name and Region Name. Select

    Breadcrumb for Breadcrumb and select Home for Parent Entry and click Next.

    6) Accept the default and click Next.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 31

    7) Enter the following SQL SELECT statement and click Next. You can copy and

    paste the SQL statement from /home/oracle/labs/scripts/commission.sql. SELECT employee_id, first_name, last_name, manager_id, commission_pct

    FROM OEHR_EMPLOYEES

    WHERE commission_pct IS NOT NULL;

    8) Click Finish.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 32

    9) Click Run Page to see the report that you just created.

    10) Your report is displayed.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 33

    11) You want to create a new computation. Click Actions and select Format > Compute.

    12) Enter New Commission for Column Heading. The computation adds .1 to a

    commission of .1 and .05 to a commission of .15. You will use the following CASE statement to perform the computation. CASE E WHEN 0.1 THEN E+0.15 WHEN 0.15 THEN E+0.05 ELSE E END

    You can use the columns list, functions list, and keypad to enter the code in the computation area or paste the previous CASE statement into the computation area. When you select Commission Pct from Columns, notice that the letter corresponding to the column appears in the computation area. This is the column alias. After entering the code, click Apply.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 34

    13) Note that the computed column now appears in the report.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 35

    14) Create a control break on the Manager ID. Click the Manager Id column header

    and click the Control Break icon. Alternatively, you can click Actions and select Format > Control Break.

    15) Note that the column is eliminated and now appears before each breakpoint in

    your report.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 36

    16) Find out the maximum commission earned by employees under each manager. Click Actions and select Format > Aggregate.

    17) Select Maximum from the function list. Select **New Commission (which is a

    computed column) from the column list and click Apply.

    18) Your report now includes the maximum commission earned by employees under

    each manager.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 37

    19) You can download a report in multiple formats. Click Actions and select

    Download.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 38

    20) Click HTML.

    21) Click OK to view the report in your Web browser.

    22) The HTML report is displayed in a new tab.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 39

    23) Click the Interactive report tab. Save all customizations that you have made to this

    report and make it available to other managers by making it a candidate report. Click Actions and select Save Report.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 40

    24) Select As Default Reports Settings from the Save drop-down list.

    25) You want to make this available to other users. However, do not want to make it

    the default report. Select Alternative for Default Report Type, enter Commission Proposal for Name, and click Apply.

    26) The alternative report is now listed in the Reports drop-down list.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 41

    27) Select the Primary Report from the Reports drop-down list.

  • Copyright 2010, Oracle and/or its affiliates. All rights reserved.

    Practices for Lesson 5: Creating Reports Chapter 5 - Page 42

    Practice Solution 5-2: Customizing an Interactive Report

    Overview In this practice, you customize the interactive report that you created in the previous practice.

    Tasks a. As a developer, you can change the way that the interactive report is rendered for all

    users. In this practice, you make the following customizations to the Commission Report: Hide the EMPLOYEE_ID column and change the MANAGER_ID to be the

    FIRST_NAME and LAST_NAME of the manager. Remove the Highlight option from the Actions menu. Add XLS and PDF download formats. Remove the Single Row View icon for each row in the report.

    1) Navigate to the Commission Report page in your Order Management Application.

    Under Regions > Body, double-click Commissions Report.

    2) Select