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

  Create a problem definition for williwonk

Create a problem definition for Williwonk's, as described in Problem 1. Estimate the weights of importance. Include at least one requirement and one constraint.

  Question 1 calculate the tax on an ordercomplete the

question 1. calculate the tax on an ordercomplete the following steps to create a procedure to calculate the tax on an

  Security and privacy issues in internet of things

You are required to prepare and submit a report on your topic to address the following questions (the length of the report within 1500~2000 words, excluding references):

  Write a program in towers of hanoi

How to write a program in towers of hanoi using pl/sql language

  Write a query to display the starting salary

Write a query to display the starting salary for each employee. The starting salary would be the entry in the salary history with the oldest salary start date for each employee. Sort the output by employee number.

  Median-of-three partitioning method

Show the steps of partitioning  36, 38, 8, 31, 19, 15, 14, 35, 20, 7  with median-of-three partitioning method  (only show the first partition into 3 subparts, elements are less than pivot, pivot, elements are larger than pivots).

  Prepare heritage data for classification learning

Load heritage data release 3 (preprocessed to binary representation, including demographics and output attribute(s)) - Perform exploratory analysis - Create at least three classification models for predicting hospitalization based on Year 1 data.

  Limited number of copies of items designed

Quixotic Unique Manufacturing, LLC, uses 3D printing and other processes to make a limited number of copies of items designed or requested by predominantly web-based customers.

  Write an sql drop statements that will drop the all tables

Write an SQL DROP statements that will drop the all tables. Add these statements to the appropriate location within the script file - Write a SQL CREATE TABLE statement to create the ALLOCATION table. Add the SQL statement to the appropriate locati..

  Create a ssis package to implement incremental processing

A view must be created to allow DigitalX employees to view all the products on backorder and the quantity of each on order. Your view must aggregate the data from the backorder products so that each product appears only once in the list.

  Explain the primary purpose of a primary key in a database

Describe a situation in which you have used a database recently and Explain the primary purpose of a primary key in a database.

  Create the sql queries

Create the queries listed below: (Just write the SQL command for each query), RIDER - POINT TOTALS BY RACE LEVEL LISTING, List the Rider's Name, RaceLevel as Race_Level and the total number of all points based on their placement. Make sure that you..

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