Create the procedure in sql developer

Assignment Help PL-SQL Programming
Reference no: EM131415513

Assignment 1: Using the DBMS_ALERT Package

Brewbean's wants to add an alert in the product management page to advise the manager of a product stock level falling below the reorder point. The alert simply needs to state which product needs reordering.
1. Start SQL Developer, if necessary.
2. Create a database trigger on the BB_PRODUCT table, using the DBMS_ALERT package to send an alert when the stock value falls below the reorder value. Name the alert reorder and have it contain a message stating that a product needs to be reordered. Include the product number in the message.
3. If an error is raised because you don't have permission to use the DBMS_ALERT package, you need to log on as SYSDBA and enter the following command to grant the necessary permissions. (This code assumes you're the user PLBOOK.) GRANT EXECUTE ON DBMS_ALERT TO PLBOOK;
4. Start a second session of SQL Developer as SYSTEM MANAGER.
5. Type and run the following block to register the alert: BEGIN DBMS_ALERT.REGISTER('reorder'); END;
6. Type and run the following block to initiate the wait for an alert: DECLARE lv_msg_txt VARCHAR2(25); lv_status_numNUMBER(1); BEGIN DBMS_ALERT.WAITONE('reorder', lv_msg_txt, lv_status_num, 120); DBMS_OUTPUT.PUT_LINE('Alert: '|| lv_msg_txt); DBMS_OUTPUT.PUT_LINE('Status: '|| lv_status_num); END;
7. The preceding code sets a wait period of two minutes. Return to the first SQL Developer session. Type and run the following code to cause the alert to fire: UPDATE bb_product SET stock = stock - 2 WHERE idproduct = 4; COMMIT;
8. Return to the second SQL Developer session. The alert message should be displayed.

Assignment 2: Using the DBMS_DDL Package
Because Brewbean's is in the middle of constructing its application and making several database modifications, the developers are going to build a procedure to recompile all invalid objects automatically.
1. Start SQL Developer, if necessary.
2. Type and run the following code: SELECT object_name, status FROM user_objects WHERE object_type = 'PROCEDURE';
3. If you see the BB_JOBTEST procedure listed with a VALID status onscreen, skip to Step 7. If this procedure doesn't exist, proceed with Step 4.
4. Open the assignment02.txt file in the Chapter10 folder, and use its code to create the BB_JOBTEST procedure.
5. Type and run the following code: SELECT object_name, status FROM user_objects WHERE object_type = 'PROCEDURE';
6. Verify that the query results list BB_JOBTEST with a VALID status, which tells you the procedure exists.
7. Type and run the following statement to modify the BB_JOBQ table. Because the BB_JOBTEST procedure uses this table, the procedure changes to the status INVALID, indicating the need for recompiling. ALTER TABLE bb_jobq MODIFY (msg VARCHAR2(30));
8. Type and run the following query to confirm the status INVALID: SELECT object_name, status FROM user_objects WHERE object_type = 'PROCEDURE';
9. Create an anonymous block, using DBMS_DDL.ALTER_COMPILE to compile all INVALID objects. To simplify this process, retrieve all the INVALID objects in a cursor. Run the anonymous block.
10. Type and run the following query to confirm that these objects' status is now VALID: SELECT object_name, status FROM user_objects WHERE object_type = 'PROCEDURE';

Assignment 3: Using the UTL_FILE Package to Read and Insert Data
Brewbean's has struck a deal with a new tea product supplier, who has sent a test file showing how files containing product names and descriptions will be submitted. Create a PL/SQL block, using the UTL_FILE package, to read from the file and insert data in the BB_PRODUCT table.
1. Start Windows Explorer. Open the tea.txt file in the Chapter10 folder. Check the file's contents to confirm that it contains product names and descriptions, and review the data's format.
2. Start SQL Developer, if necessary.
3. Create an anonymous block that reads each line in the tea.txt file and inserts the values in the BB_PRODUCT table. Use the UTL_FILE reading feature in a loop to read each line from the text file.
4. Run the block to perform the INSERT statements.
5. Type and run the following code. The results should display the three tea products from the tea.txt file. SELECT productname, description FROM bb_product;

Assignment 4: Using the UTL_FILE Package to Export Data ColumnsTheBrewbean's manager wants to have a file extracted from the database containing product information for inventory and cash flow analysis. The manager uses this file in spreadsheet software on a laptop computer. Using the UTL_FILE package, create a PL/SQL block that places data columns in a comma-delimited text file named prod_ext.txt in the c:\oraclass directory. The extracted file should contain one line per product and the following columns of the BB_PRODUCT table: IDPRODUCT, PRODUCTNAME, PRICE, TYPE, STOCK, ORDERED, and REORDER.

Assignment 5: Sending E-mail with UTL_SMTP
The Brewbean's manager decided he wants to get e-mail notifications when product stock levels fall below the reorder point. Create the BB_STKALERT_TRG trigger on the BB_PRODUCT table to perform this task. The e-mail body should state the product ID and name. Use the following UPDATE statement to set up a product to test:
UPDATE bb_product
SET stock = 26 WHERE idProduct = 4;
COMMIT;
Test the trigger with this code:
UPDATE bb_product
SET stock = stock - 2
WHERE idproduct = 4;
COMMIT;
When you finish the assignment, disable the trigger so that it doesn't affect other assignments.

Assignment 6: Using DBMS_OUTPUT Using the DBMS_OUTPUT package, create and run a PL/SQL block that displays lines for each product in the BB_PRODUCT table. If the stock level for a product is above the reorder point, only a single line should be displayed that looks like the following code:
Product 5 - Sumatra does NOT need ordering
If the stock level is below the reorder point, lines such as the following should be displayed:
Product 5 - Sumatra needs ordering!
Stock = 24 , reorder point = 25
Before running the block, issue the following statements to make sure product 4's stock level is below the reorder point:
UPDATE bb_product
SET stock = 24 WHERE idProduct = 4;
COMMIT;

Assignment 7: Using the DBMS_SQL Package

Brewbean's employees want an application page where they can query the CUSTOMER table for ID and last name based on one criterion on any customer information column. To perform this task, you create a procedure by using DBMS_SQL to set up a dynamic query. Name the procedure DYN_CUST_SP and verify that the procedure works by issuing two queries: one with the state NC and one with the e-mail value [email protected]. Keep in mind that any column can be used as a criterion, which could result in the query returning more than one row. For example, two customers might have the same last name. Therefore, this procedure needs to be able to handle multiple rows being returned.

1. Start SQL Developer, if necessary.

2. Open the assignment07.txt file in the Chapter10 folder, and use its code to create the DYN_CUST_SP procedure.

3. Next, you need to run the procedure with the two test cases. First, use the STATE column criteria, and run an anonymous block that includes the statement dyn_cust_sp ('state', 'NC');.

4. Now check the customer e-mail address by using an anonymous block that includes the statement dyn_cust_sp('e-mail', '[email protected]');.

Assignment 8: Using Native Dynamic SQL to Add ColumnsTheBrewbean's manager wants an application page that makes it easy for employees to add columns to the database. Create a procedure that accepts input and uses native dynamic SQL to perform this task. Test the procedure by adding a column named MEMBER to the BB_SHOPPER table with the data type CHAR(1).

1. Start SQL Developer, if necessary.

2. Open the assignment08.txt file in the Chapter10 folder. Review the uncompleted procedure code, and then finish the EXECUTE IMMEDIATE statement to allow column additions.

3. Create the procedure in SQL Developer.

4. Run the procedure by using the following block to add the MEMBER column: BEGIN dyn_addcol_sp('member','bb_shopper','CHAR(1)'); END;

5. Type DESC bb_shopper and press Enter to list the table structure and confirm the addition of the MEMBER column.

Assignment 9: Using Native Dynamic SQL for Product SearchesBrewbean's wants to allow customers to do product search by selecting a product name or description, and then typing a search term. Using native dynamic SQL, create a procedure named SEARCH_SP that returns the product name, description, and price based on users' search criteria. This procedure needs to handle multiple rows being returned.

Assignment 10: Understanding Business Intelligence
Business intelligence (BI) is a term used to describe providing more database power for users. Describe briefly what it means in applications, including the terms "data mining," "data marts," "OLAP," and "executive dashboards." What role might dynamic SQL play in BI? Describe BI products that Oracle offers.

Assignment 11: Using the Wrap Utility
In this assignment, you show how to use the Oracle wrap utility to obfuscate the BB_JOBTEST procedure's source code. Create an .sql file (job.sql) using the script file for the procedure (available in assignment02.txt in the Chapter10 folder of the data files). Use the wrap utility on the job.sql file to hide the script's source code. Check the file the utility produces.

Verified Expert

Appropriate tables and appropriate packages were implemented for each assignment. implemented the different packages like DBMS_alert, DDL,UTL_FILE, UTL_SMTP etc. PL/SQL concepts were applied for the store management. done the send and receive the emails using the UTL_SMTP package for the assignment 5. Explained the business intelligence concepts for the 10th assignment.

Reference no: EM131415513

Questions Cloud

Structure selections- parental consent for minors abortion : If the parents can veto a minor's abortion, shouldn't they also be able to require one? Better the choice, either pro or con, be left to the girl/woman herself.
Us airways and american airlines merger : Given the recent events in the US Airways and American Airlines merger, one has to wonder, is the airline industry monopolistic? Which is worse, monopolies or competition? Explain your answer.
Compares legal and illegal actions : Compares legal and illegal actions, as Sextus did in D, to show the impossibility of making moral judgments
Composition and intent relative to product development teams : Are integrated product teams any different in composition and intent relative to product development teams. What are the reasons for encouraging managers to use the stakeholder approach? Would these reasons apply to teams?
Create the procedure in sql developer : Create the procedure in SQL Developer - Run the procedure by using the following block to add the MEMBER column: BEGIN dyn_addcol_sp('member','bb_shopper','CHAR(1)'); END;
Compute the cash payments made to suppliers during 2008 : Assume that accounts payable reflects only accounts with inventory suppliers, and compute the cash payments made to suppliers during 2008.
Few to a greater number of individuals : Discuss ways in which technology challenges authority and aids in the redistribution of the power held by a few to a greater number of individuals. (You may wish to be specific, such as the stirring up of European society.)
What are the characteristics of romantic love : What are the characteristics of romantic love? What is the effect of time on romance? What other factors influence romantic love
Limits on employer and union campaigning : Do you think there should be any limits on employer and union campaigning? Give reasons to support your answer. If you agree, what type of limits would you suggest?

Reviews

Write a Review

PL-SQL Programming Questions & Answers

  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).

  You may want to build a database with the required tables

In order to test your program, you may want to build a database with the required tables.  However, the database is not part of the assessment of the assignment.

  Write the sql code to perform the tasks

Write the SQL code to perform the tasks requested in each problem. Define a new containing the product number, name, price, and quantity on hand along with the number of orders in which the product appears.

  A duplicate eliminating projection

Consider the following SQL query over tables R(A), S(A), and T (A). Note that "Select Distinct" in SQL represents a duplicate-eliminating projection.

  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.

  List the average cost of projects for employees

List the average cost of projects for employees who weakness is "no super power" and the average cost of projects for all other employees, create a new column that labels each total (use UNION ALL).

  Describe all system privileges found in sql server

Describe all system privileges found in SQL Server

  Describe conceptually how an sql retrieval query

Question 1: Describe conceptually how an SQL retrieval query will be executed by specifying the conceptual order of executing each of the six clauses?

  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 don't list any riders who have not raced in any races yet (not placed yet).

  List the name and country of all athletes

List the name and country of all athletes. List the event name and scheduled start time for all events held in the Velodrome. List the names of athletes who competed in an event in Rio de Janeiro, Sao Paolo, or both.

  Create a table that includes a rotating schedule

Create a table that includes a rotating schedule for the 12 months of security testing. Include columns that identify time estimations for each test listed.

  Attempt the following1 run the lab0301sql script in the

attempt the following1. run the lab0301.sql script in the attached file to create the salhistory table. 2. display the

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