Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask PL-SQL Expert

Consider the following set of database tables (same tables from Assignment 6-1). Please take note of foreign keys (most of them carry the same names as the corresponding primary keys they reference): CUS_CODE in INVOICE, INV_NUMBER & P_CODE in LINE, and V_CODE in PRODUCT. The only exception to the naming convention is the EMP_MGR foreign key in EMPLOYEE which references the EMPLOYEE table in a recursive relationship.

The SQL script file myCompany.SQL (same one from Assignment 6-1) creates the tables below and inserts data into them. You WILL need to rerun the script again for this assignment since the contents of some of the files were altered during assignment 6-1. You should also run the script again before final submission of this assignment. Click HERE if you need the script again.

PS: As a reminder, your SQL statements should be generic enough to produce proper results EVEN if the data inside the database changes. For example, if I ask you to display the products provided by vendors located in TN, you can't manually extract the V_CODE for vendors in TN and use the results to search table PRODUCT for the corresponding products; instead, your query should be written using a join between the two tables or something similar.

I. Part 1: Writing More Complex SQL Queries: Save the SQL code for the following queries a single script file called Part1.sql. In addition, include each query along with its output in your report.

1. Create an SQL query that uses set operations to display the union of the last names in table CUSTOMER and the last names in table EMPLOYEE. Do not include duplicates in the output.

2. Create an SQL query that uses set operations to display the union of the last names in table CUSTOMER and the last names in table EMPLOYEE. This time, include duplicates in the output.

3. Create an SQL query that USES AN UNCORRELATED SUBQUERY1 AND NO JOINS2 to display the descriptions for products provided by a vendor in area code 615.

4. Create an SQL query that USES A CORRELATED SUBQUERY AND NO JOINS to display the descriptions for products provided by a vendor in area code 615.

II. Part 2: Creating and Executing a Stored Procedure: Save the SQL code for this stored procedure in a separate script file called Part2.sql. In addition, include the test steps - see below - along with their output in your report. Finally, answer the question below in your report.

Create an SQL Stored Procedure called prc_inv_delete that takes an invoice number as a parameter and deletes the invoice from table INVOICE. TEST STEPS: To test your procedure, do the following:

a) Run the following two SQL commands: SELECT * from INVOICE WHERE INV_NUMBER IN (1001, 1008); SELECT * from LINE WHERE INV_NUMBER IN (1001, 1008);

b) Execute your procedure to delete invoices 1001 and 1008.

c) Run the same SQL commands again: SELECT * from INVOICE WHERE INV_NUMBER IN (1001, 1008); SELECT * from LINE WHERE INV_NUMBER IN (1001, 1008);

d) Undo all changes made by issuing a rollback command.

Answer this question: Did the corresponding lines for invoices 1001 and 1008 in table LINE get deleted automatically? Can you explain why?

PL-SQL, Programming

  • Category:- PL-SQL
  • Reference No.:- M9522150

Have any Question?


Related Questions in PL-SQL

For this assignment you will be provided a database backup

For this assignment, you will be provided a database backup for a database called FinanceDB. You will have to restore this backup to your own version of SQL Server. All of the questions in this assignment relate to the F ...

Assignment - queries functions and triggersaimthe aims of

Assignment - Queries, Functions and Triggers Aim The aims of this assignment are to: formulate SQL queries; populate an RDBMS with a real dataset, and analyse the data; design test data for testing SQL queries; create SQ ...

Complete the following tasksin microsoft access create the

Complete the following tasks: In Microsoft Access, create the database and tables that you identified in W3 Assignment 2. In Microsoft Word, write the SQL statements to create the database and tables. Write SQL statement ...

Continuing the project you have worked on in weeks 1-4 in

Continuing the project you have worked on in Weeks 1-4, in this final week, complete the following tasks: Refine your database and SQL statements by incorporating your instructor's feedback. Verify that the database comp ...

Purpose of the assessment with ulo mapping the purpose of

Purpose of the assessment (with ULO Mapping) The purpose of this assignment is to develop skills in managing data in databases and to gain understanding of data model development and implementation using a commercially a ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As