Create a package containing a procedure and a function

Assignment Help PL-SQL Programming
Reference no: EM131393615

Assignment 1: Creating a Package

Follow the steps to create a package containing a procedure and a function pertaining to basket information. (Note: The first time you compile the package body doesn't give you practice with compilation error messages.)

1. Start Notepad, and open the Assignment07-01.txt file in the Chapter07 folder.

2. Review the package code, and then copy it.

3. In SQL Developer, paste the copied code to build the package.

4. Review the compilation errors and identify the related coding error.

5. Edit the package to correct the error and compile the package.

Assignment 2: Using Program Units in a Package

In this assignment, you use program units in a package created to store basket information. The package contains a function that returns the recipient's name and a procedure that retrieves the shopper ID and order date for a basket.

1. In SQL Developer, create the ORDER_INFO_PKG package, using the Assignment07-02.txt file in the Chapter07 folder. Review the code to become familiar with the two program units in the package.

2. Create an anonymous block that calls both the packaged procedure and function with basket ID 12 to test these program units. Use DBMS_OUTPUT statements to display values returned from the program units to verify the data.

3. Also, test the packaged function by using it in a SELECT clause on the BB_BASKET table. Use a WHERE clause to select only the basket 12 row.

Assignment 3: Creating a Package with Private Program Units

In this assignment, you modify a package to make program units private. The Brewbean's programming group decided that the SHIP_NAME_PF function in the ORDER_INFO_PKG package should be used only from inside the package. Follow these steps to make this modification:

1. In Notepad, open the Assignment07-03.txt file in the Chapter07 folder, and review the package code.

2. Modify the package code to add to the BASKET_INFO_PP procedure so that it also returns the name an order is shipped by using the SHIP_NAME_PF function. Make the necessary changes to make the SHIP_NAME_PF function private.

3. Create the package by using the modified code.

4. Create and run an anonymous block that calls the BASKET_INFO_PP procedure and displays the shopper ID, order date, and shipped-to name to check the values returned. Use DBMS_OUTPUT statements to display the values.

Assignment 4: Using Packaged Variables

In this assignment, you create a package that uses packaged variables to assist in the user logon process. When a returning shopper logs on, the username and password entered need to be verified against the database. In addition, two values need to be stored in packaged variables for reference during the user session: the shopper ID and the first three digits of the shopper's zip code (used for regional advertisements displayed on the site).

1. Create a function that accepts a username and password as arguments and verifies these values against the database for a match. If a match is found, return the value Y. Set the value of the variable holding the return value to N. Include a NO_DATA_FOUND exception handler to display a message that the logon values are invalid.

2. Use an anonymous block to test the procedure, using the username gma1 and the password goofy.

3. Now place the function in a package, and add code to create and populate the packaged variables specified earlier. Name the package LOGIN_PKG.

4. Use an anonymous block to test the packaged procedure, using the username gma1 and the password goofy to verify that the procedure works correctly.

Assignment 5: Overloading Packaged Procedures

In this assignment, you create packaged procedures to retrieve shopper information. Brewbean's is adding an application page where customer service agents can retrieve shopper information by using shopper ID or last name. Create a package named SHOP_QUERY_PKG containing overloaded procedures to perform these lookups. They should return the shopper's name, city, state, phone number, and e-mail address. Test the package twice. First, call the procedure with shopper ID 23, and then call it with the last name Ratman. Both test values refer to the same shopper, so they should return the same shopper information.

Assignment 6: Creating a Package with Only a Specification

In this assignment, you create a package consisting of only a specification. The Brewbean's lead programmer has noticed that only a few states require Internet sales tax, and the rates don't change often. Create a package named TAX_RATE_PKG to hold the following tax rates in packaged variables for reference: pv_tax_nc = .035, pv_tax_tx = .05, and pv_tax_tn = .02. Code the variables to prevent the rates from being modified. Use an anonymous block with DBMS_OUTPUT statements to display the value of each packaged variable.

Assignment 7: Using a Cursor in a Package

In this assignment, you work with the sales tax computation because the Brewbean's lead programmer expects the rates and states applying the tax to undergo some changes. The tax rates are currently stored in packaged variables but need to be more dynamic to handle the expected changes. The lead programmer has asked you to develop a package that holds the tax rates by state in a packaged cursor. The BB_TAX table is updated as needed to reflect which states are applying sales tax and at what rates. This package should contain a function that can receive a two-character state abbreviation (the shopper's state) as an argument, and it must be able to find a match in the cursor and return the correct tax rate. Use an anonymous block to test the function with the state value NC.

Assignment 8: Using a One-Time-Only Procedure in a Package

The Brewbean's application currently contains a package used in the shopper logon process. However, one of the developers wants to be able to reference the time users log on to determine when the session should be timed out and entries rolled back. Modify the LOGIN_PKG package (in the Assignment07-08.txt file in the Chapter07 folder). Use a one-time-only procedure to populate a packaged variable with the date and time of user logons. Use an anonymous block to verify that the one-time-only procedure works and populates the packaged variable.

Verified Expert

In this assignment the existing database of the online shopping is provided. They asked to write functions and procedures on the database to retrieve useful results from them.All the functions and procedures are written inside the package.A function private to the package is written and this function was accessed using another procedure in the same package. The package variables are assigned with the session values. The package variables are made unmodifiable and accessed via anonymous block. Overloaded procedures are written to obtain the shopper information either from their id or from the last name of the shopper. The table information are obtained in cursor and the useful data in cursor are obtained.The output are taken for each executed procedure and attached with the documentation

Reference no: EM131393615

Questions Cloud

How do diversity issues affect citizen participation : How do diversity issues affect citizen participation and again, what approaches to the analysis process might facilitate or hinder such participation?
Parts of government determine the federal budget : What two parts of government determine the federal budget? According to the quantity theory of money, when the money growth rate is significantly lower than the growth rate of potential GDP = real GDP, the economy is experiencing
Procyclical leverage and procyclical liquidity : Write an essay on the transformation of credit in the US economy. How did this happen (key events and new financial products?)? How has macroeconomics accounted for this transformation? Explain the terms ‘procyclical Leverage’ and ‘procyclical liquid..
Identify an aspect of cost-benefit analysis : Identify an aspect of cost-benefit analysis that more effectively addresses notions of equity and accounts for them in the overall policy analysis. Describe how this aspect would be applied and provide examples as much as possible.
Create a package containing a procedure and a function : Follow the steps to create a package containing a procedure and a function pertaining to basket information. (Note: The first time you compile the package body doesn't give you practice with compilation error messages.)
Explain driving forces for change in external environment : Identify and analyze the major driving forces for change in the external environment of the motorcycle industry. Analyze the dynamics of competition using Porter's Five Forces Model of Competition.
Amount of required reserves : Suppose the required reserve ratio is 20%. If a bank has a total deposit of $200 and total assets of $1000, the amount of required reserves is
What is the output voltage of a certain log amplifier : What is the output voltage of a certain log amplifier with a diode in the feedback path when the input voltage is 3 V? The input resistor is 82 KΩ and the reverse leakage current is 100 nA.
Analyze how federal-local courts calendar and docket cases : JUS 261:Jed, Herman, and Jane live in Washington, D.C. Jed and Jane entered the local bank and took $65,000. Jed and Herman both used shotguns during the robbery,though no one was hurt. Jane drove the getaway vehicle. Two hours later, as they head..

Reviews

inf1393615

2/18/2017 5:23:07 AM

Thank you, Guys!!!! EVERYTHING was flawless and I owe you guys my life!!! Not just did I get the passing evaluation from the teacher, I got the formal welcome to partake in beginning functions from the college, I can graduate!!! you all are paradise sent I will prescribe you my cousin needs to do her theory next fall, so I educated her don't stress concerning it, and guaranteed her she will have a flawlessly composed case proposal. Last Friday I was kicking the bucket, this Friday I'm excited and I owe everything to you all for your understanding and demonstrable skill. I ridiculously welcome you all requiring some serious energy with me to console me.

Write a Review

PL-SQL Programming Questions & Answers

  Provide four queries to answer questions asked by end users

Explain how you will go about developing this database. Provide at least four queries that answer some of the questions asked by the end users.

  Display the customerid from the orders table

Display the CustomerID from the Orders table and the sum of the associated ItemPrice multiplied by Quantity using Gross Sales (with a space) as the column name from the OrderItems table.

  Handling exceptions with undefined errors

The first statement, ALTER TABLE, must be executed to add the check constraint. The next item is a PL/SQL block containing an INSERT action that tests this check constraint.

  When should wildcard characters used in queries

When should wildcard characters used in queries and list the six types of wildcard characters that can be used in Access queries?

  List the items from the table

List the part number, part description, and item class for each pair of parts that are in the same item class.

  How to understand sql ddl and dml

Task one will provide a relational database implementation of the sample solution from the first assignment. This should be done using CASE software (the choice will be up to you).

  Explain entity integrity and referential integrity rules

Explain entity integrity and referential integrity rules in relational model.show how these aer realized in sql

  Possible advantages of utilizing pl-sql

A good IT professional is able to be versatile in SQL programming styles. Identify at least two possible advantages of utilizing PL/SQL instead of standard SQL Syntax.

  Question 1 write a query to display the last name

question 1 write a query to display the last name department number and salary of any employee whose department number

  Write a xquery which returns all concert titles

Write a XQuery which returns all concert titles whose type is chamber orchestra where average ticket price is at least $50.

  Construct an sql schema definition for database

Construct an SQL schema definition for this database. Use inheritance where appropriate.

  Calculate annual raises for all employees

Calculate annual raises for all employees except the president - Handling Exceptions with User-Defined Errors - Modify the anonymous block so that it displays the number of rows updated onscreen. Run the block.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd