An active database in pl-sql, PL-SQL Programming

Assignment Help:

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?


Related Discussions:- An active database in pl-sql

Transactions in sql, Transactions in SQL BEGIN TRANSACTION, COMMIT, an...

Transactions in SQL BEGIN TRANSACTION, COMMIT, and ROLLBACK, SQL has the same syntax except for START in place of BEGIN. However, START TRANSACTION is used only for outermost

Assignment2, How do I display usernames for students from a student table, ...

How do I display usernames for students from a student table, assigning each student a username initials001 (initials is the actual student initials), and if the students initials

Stored subprograms, Stored Subprograms Normally, tools (like Oracle Fo...

Stored Subprograms Normally, tools (like Oracle Forms) which incorporate the PL/SQL engine can store subprograms locally for later, strictly local execution. Though, to become

Maintain an audit trail of product table changes, The accuracy of product t...

The accuracy of product table data is critical and the Brwebean's. owner wants to have an audit file that contains information regarding all DML activity on the BB_PRODUCT table. T

Parameter modes - pl sql, Parameter Modes: You do not require to speci...

Parameter Modes: You do not require to specify a parameter mode for the input bind arguments (those used, for illustration, in the WHERE clause) as the mode defaults to IN. Th

Left and right joins, Left and Right Joins LEFT OUTER JOIN can be used...

Left and Right Joins LEFT OUTER JOIN can be used when you want to retrieve the data from the main table (table1) even if there is no match in other tables (table_2, table_3...

Currval and nextval - sql pseudocolumns, CURRVAL and NEXTVAL The serie...

CURRVAL and NEXTVAL The series is a schema object which generates the sequential numbers. Whenever you form a sequence, you can specify its primary value and an increment. T

Joining in sql, Joining in SQL Joining IS_CALLED and IS_ENROLLED_ON in...

Joining in SQL Joining IS_CALLED and IS_ENROLLED_ON in SQL SELECT * FROM IS_CALLED NATURAL JOIN IS_ENROLLED_ON This is an example of an SQL table expression. I have been

I need a ppd-cpa or filesharing site, PPD , CPA, Filesharing Site Projec...

PPD , CPA, Filesharing Site Project Description: This is very easy I need a PPD , CPA, Filesharing Site. [PPD] stands for (pay per download) example hotsharecash [Files

Updating variables, Updating Variables For assignment, SQL uses the ke...

Updating Variables For assignment, SQL uses the key word SET, as in SET X = X + 1 (read as "set X equal to X+1") rather than X: = X + 1 as found in many computer languages.

Write Your Message!

Captcha
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