











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A comprehensive overview of procedures and functions in the oracle database. It covers the definition, creation, and execution of stored procedures and functions, as well as their advantages and how the oracle engine handles them. The document also includes an example of a procedure called 'proc_update' that updates the quantity in hand in the product_master table and the order status in the sales_order table. The example demonstrates how the procedure is called within a pl/sql block to simplify the process of updating related tables. Topics such as the syntax for creating a procedure, how to delete a stored procedure, and the steps the oracle engine takes to execute a procedure or function. Overall, this document serves as a valuable resource for understanding the fundamentals of procedures and functions in the oracle database and how they can be utilized to improve database performance, security, and productivity.
Typology: Schemes and Mind Maps
1 / 19
This page cannot be seen from the preview
Don't miss anything!
Where do Stored Procedures and Functions Reside?
How the Oracle engine creates a Procedure/Function?
1. Security: Stored procedures can help enforce data security. 2. Performance: It improves database performance in the following ways:
3. Memory Allocation: The amount of memory used reduces as stored procedures have shared memory capabilities. Only one copy of procedure needs to be loaded for execution by multiple users. Once a copy of the procedure is opened in the Oracle engine’s memory, other users who have permissions may access them when required. 4. Productivity: By writing procedures redundant coding can be avoided, increasing productivity. 5. Integrity: A procedure needs to be tested only once to guarantee that it returns an accurate result. Since procedures are stored in the Oracle engine’s they become a part of the engine’s resource. Hence the responsibility of maintaining their integrity rests with the Oracle Engine.
How To DELETE A Stored Procedure?
Example
Table: Challan_Details Column Name Data Type Size Attributes Challan_no Varchar2 6 PK/FK references Challan_no of Challan_header Table Product_no Varchar2 20 PK/FK references product_no of product_master Table Qty_disp Number 10,2 Not Null Table: Challan_Header Column Name Data Type Size Attributes Challan_no Varchar2 6 PK / First two letters must start with ‘CH’. Order_no Varchar2 20 FK references s_order_no of sales_order Table. Challan_Date Date Not Null. Billed_yn Char 1 Values (‘Y’,’N’). Default ‘N’
Table: Sales_Order Column Name Data Type Size Attributes Order_no Varchar2 6 PK / First two letters must start with ‘O. Order_date date Client_no Number 10,2 FK references client_no of client_master table. Dely_Addr Varchar2 25 Salesman_No Varchar2 6 FK references salesman_no of salesman_master table Dely_Type Char 1 Billed_yn Char 1 Dely_date Date can’t be less than order date Order_Status Varchar2 10 Values (In Process, Fulfilled, BackOrder or Cancelled)
CREATE OR REPLACE PROCEDURE proc_update (vproductno IN char, vsorderno IN char, quantity IN number) IS Total_qty_ordered number (8); Total_qty_disp number (8); BEGIN UPDATE product_master SET qty_in_hand = qty_in_hand-quantity (/Updating the qty_in_hand in product_master table/) WHERE product_no = vproductno; SELECT sum(qty_ordered), sum (qty_disp) (/Checking in the sales_order_details table the total INTO total_qty_ordered, total_qty_disp quantity ordered and the total quantity dispatched FROM sales_order_details for a certain sales_order and stuffing the values WHERE delorder_no=vsorderno; into memory variables /) IF total_qty_ordered = total_qty_disp THEN UPDATE sales_order SET order_status = ‘Fulfilled’(/ Comparing the total_quantity ordered with WHERE order_no = vsorderno; the total quantity dispatched and updating the ELSIF total_qty_disp = 0 THEN order_status in sales_order table/) UPDATE sales_order SET order_status = ‘Backorder’ WHERE order_no = vsorderno; Else UPDATE sales_order SET order_status = ‘In Process’ WHERE order_no = vsorderno; END IF; END;
The functionality of the PL/SQL block of code will be as follows: