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

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?

Posted Date: 2/15/2013 5:42:17 AM | Location : United States







Related Discussions:- An active database in pl-sql, Assignment Help, Ask Question on An active database in pl-sql, Get Answer, Expert's Help, An active database in pl-sql Discussions

Write discussion on An active database in pl-sql
Your posts are moderated
Related Questions
Advantages of Invoker Rights The Invoker-rights routines centralize the data retrieval. They are particularly helpful in applications which store data in various schemas. In su

Need Windows and Linux system Administrator We are seeking a part time system administrator to take care of our servers. Your things to do would add, but not limited to: -

Explicitly specifying the join condition - SQL SELECT * FROM IS_CALLED JOIN IS_ENROLLED_ON ON ( IS_CALLED.StudentId = IS_ENROLLED_ON.StudentId ) Now, the key word JO

Due to an increase in overhead costs, the buying price of all items needs to be increased. Management wants to see a report before deciding how much each product will go up. Add to

Main features of PL/SQL A good way to get familiar with PL/SQL is to look at a sample program. The below program processes an order for tennis rackets. At first, it declares a

Declarations in SQL Your program stores values in the variables and constants. As the program executes, the value of the variables can change, but the values constants cannot.

Keyword & Parameter Description: WHEN: This keyword introduces the exception handler. You can have many exceptions execute the similar sequence of the statements by follo

COMMIT Statement The COMMIT statement explicitly makes everlasting changes to the database during the present transaction. The Changes made to the database are not considered e

Example of Null operator - NiNo Rule If we wanted to make HIGHER_OF adhere to "NULL in, NULL out"-let's call it the NiNo rule-we would have to write something like what is sho

Named Notation The second procedure call uses the named notation. An arrow (=>) serve as the relationship operator that associates the formal parameter to the left of the arro