
Concept explainers
a.
Stored procedures:
- A procedure is a collection of procedural and SQL statements.
- A procedure may have input parameter, output parameter and both parameters.
- It has a declared with a unique named with a unit of procedural code using the proprietary RDBMS and it is invoked by a host language library routine.
Syntax for stored procedure:
CREATE FUNCTION fun_name(argument IN data-type)RETRUN data-type[IS]
BEGIN
PL/SQL statements;
Return (value or expression);
END;

Explanation of Solution
Query to create stored procedure:
CREATE OR REPLACE PROCEDURE DISP_CUST_CRED (I_CUSTOMER_NUM IN CUSTOMER.CUSTOMER_NUM%TYPE) AS
I_CUSTOMER_NAME CUSTOMER.CUSTOMER_NAME%TYPE;
I_CREDIT_LIMIT CUSTOMER.CREDIT_LIMIT%TYPE;
BEGIN
SELECT CUSTOMER_NAME, CREDIT_LIMIT
INTO I_CUSTOMER_NAME, I_CREDIT_LIMIT
FROM CUSTOMER
WHERE CUSTOMER_NUM = I_CUSTOMER_NUM;
DBMS_OUTPUT.PUT_LINE (I_CUSTOMER_NAME);
DBMS_OUTPUT.PUT_LINE (I_CREDIT_LIMIT);
END;
/
Explanation:
- The above query is used to create a procedure named “DISP_CUST_CRED” to select the records in the “CUSTOMER” table.
- Change the “CUSTOMER_NUM” into “I_CUSTOMER_NUM” and place the “CUSTOMER_NAME” and “CREDIT_LIMIT” values into “I_CUSTOMER_NAME” and “I_CREDIT_LIMIT”.
- After placing these values, display the “I_CUSTOMER_NAME” and “I_CREDIT_LIMIT” from the “CUSTOMER” table.
- Once the stored procedure is created, it needs to be executed.
Query to view the customer name and credit limit:
BEGIN
DISP_CUST_CRED (126);
END;
The above query is used to view the customer name and credit limit for the number 126.
Output:
Toys Galore
7500
Explanation of Solution
b.
Query to create stored procedure:
CREATE OR REPLACE PROCEDURE DISP_ORDERS (I_ORDER_NUM ORDERS.ORDER_NUM%TYPE) AS
I_ORDER_DATE ORDERS.ORDER_DATE%TYPE;
I_CUSTOMER_NUM CUSTOMER.CUSTOMER_NUM%TYPE;
I_CUSTOMER_NAME CUSTOMER.CUSTOMER_NAME%TYPE;
BEGIN
SELECT ORDER_DATE, CUSTOMER.CUSTOMER_NUM, CUSTOMER_NAME
INTO I_ORDER_DATE, I_CUSTOMER_NUM, I_CUSTOMER_NAME
FROM ORDERS, CUSTOMER
WHERE ORDERS.CUSTOMER_NUM = CUSTOMER.CUSTOMER_NUM
AND ORDER_NUM = I_ORDER_NUM;
DBMS_OUTPUT.PUT_LINE(I_ORDER_DATE);
DBMS_OUTPUT.PUT_LINE(I_CUSTOMER_NUM);
DBMS_OUTPUT.PUT_LINE(I_CUSTOMER_NAME);
END;
/
Explanation:
- The above query is used to create a procedure named “DISP_ORDERS” to select the records in the “CUSTOMER” and “ORDERS” tables.
- Change the “ORDER_NUM” into “I_ORDER_NUM” and place the “ORDER_DATE”, “CUSTOMER_NUM”, and “CUSTOMER_NAME” values into “I_ORDER_DATE”, “I_CUSTOMER_NUM”, and “I_CUSTOMER_NAME”.
- After placing these values, display the “I_ORDER_DATE”, “I_CUSTOMER_NUM”, and “I_CUSTOMER_NAME” from the “CUSTOMER” and “ORDERS” tables.
- Once the stored procedure is created, it needs to be executed.
Query to view the order date, customer name and customer number:
BEGIN
DISP_ORDERS (51608);
END;
The above query is used to view the order date, customer name and customer number for the number 51608.

Output:
10/12/2015
126
Toys Galore
Explanation of Solution
c.
Query to insert the value:
CREATE OR REPLACE PROCEDURE ADD_ORDER
(I_ORDER_NUM IN ORDERS.ORDER_NUM%TYPE,
I_ORDER_DATE IN ORDERS.ORDER_DATE%TYPE,
I_CUSTOMER_NUM IN ORDERS.CUSTOMER_NUM%TYPE) AS
BEGIN
INSERT INTO ORDERS (ORDER_NUM, ORDER_DATE, CUSTOMER_NUM)
VALUES
(I_ORDER_NUM, I_ORDER_DATE, I_CUSTOMER_NUM);
END;
/
Explanation:
The above query is used to create a stored procedure named “ADD_ORDER” to insert the new record in the “ORDERS” table. Once the stored procedure is created, it needs to be executed.
Query to execute the stored procedure:
BEGIN
ADD_ORDER (51627,'10/16/2015', 334);
END;
After executing the above query, the new record is inserted into the table “ORDERS”.

Output:
Query to view the contents in “ORDERS” table is as follows:
SELECT * FROM ORDERS;
Screenshot of output
Explanation of Solution
d.
Query to update stored procedure:
CREATE OR REPLACE PROCEDURE UPDATE_ORDER_DATE
(I_ORDER_NUM IN ORDERS.ORDER_NUM%TYPE,
I_ORDER_DATE IN ORDERS.ORDER_DATE%TYPE) AS
BEGIN
UPDATE ORDERS
SET ORDER_DATE = I_ORDER_DATE
WHERE ORDER_NUM = I_ORDER_NUM;
END;
/
Explanation:
The above query is used to create a stored procedure named “UPDATE_ORDER_DATE” to update the date of the order whose number is stored in “I_ORDER_DATE” to the date presently found in “I_ORDER_DATE”, it needs to be executed.
Executing the stored procedure:
The Content of “ORDERS” table before creating the procedure is given below:
Query to view the contents in “ORDERS” table is as follows:
SELECT*FROM ORDERS;
Screenshot of output
Query to execute the stored procedure:
BEGIN
UPDATE_ORDER_DATE (51614, '02/12/2019');
END;
/
After executing the above query, the date is changed in the table “ORDERS”.

Output:
Query to view the contents in “ORDERS” table is as follows:
SELECT * FROM ORDERS;
Screenshot of output
Explanation of Solution
e.
Query to delete the value:
CREATE OR REPLACE PROCEDURE DELETE_ORDERS
(I_ORDER_NUM ORDERS.ORDER_NUM%TYPE) AS
BEGIN
DELETE
FROM ORDERS
WHERE ORDER_NUM = I_ORDER_NUM;
END;
/
Explanation:
- The above query is used to create a procedure named “DELETE_ORDERS” to delete a record in the “ORDERS” table.
- Once the record is deleted, a procedure should create order number as a parameter.
- Once the stored procedure is created, it needs to be executed.
Executing the stored procedure:
The Content of “ORDERS” table before creating the procedure is given below:
Query to view the contents in “ORDERS” table is as follows:
SELECT * FROM ORDERS;
Screenshot of output
Query to execute the stored procedure:
BEGIN
DELETE_ORDERS (51613);
END;
The above query is used to delete the order number 51613.

Output:
Query to view the contents in “ORDERS” table after deleting the order number 51613 as follows:
SELECT * FROM ORDERS;
Screenshot of output
Want to see more full solutions like this?
Chapter 8 Solutions
A Guide to SQL
- Simplify the following expressions by means of a four-variable K-Map. AD+BD+ BC + ABDarrow_forwardCSE330 Discrete Mathematics 1. In the classes, we discussed three forms of floating number representations as given below, (1) Standard/General Form, (2) Normalized Form, (3) Denormalized Form. 2. Let ẞ 2, m = 6, emin = -3 and emax = 3. Answer the following questions: Compute the minimum of |x| for General and Normalized form (a) Compute the Machine Epsilon value for the General and Denormalized form. If we change the value of emax to 6 then how will it affect the value of maximum scale invariant error for the case of Normalized form? Explain your answer. show answer in pen a Don't use any Al tool nd paper then take pi ctures and sendarrow_forwardCSE330: Discrete Mathematics 1. In the classes, we discussed three forms of floating number representations as given below, (1) Standard/General Form, (2) Normalized Form, (3) Denormalized Form. Now, let's take, ẞ = 2, m = 3, emin = -2 and emax = 3. Based on these, answer the following: (a) (b) (c) (d) What are the maximum/largest numbers that can be stored in the system by these three forms defined above? (express your answer in decimal values) What are the non-negative minimum/smallest numbers that can be stored in the system by the denormalized form? (express your answer in decimal values) How many numbers (both non-negative and negative) can be represented in the above mentioned system using the general form? Explain your answer. Find all the decimal numbers for e = 3 and e = 2 in denormalized form, plot them on a real line and prove that all the numbers are not equally spaced. Write the equally spaced sets for the number line you drew. show your answer in Don't use any Al tool pen…arrow_forward
- 3.[20 pts] Find the minimum equivalent circuit for the one shown below (show your work): DAB 0 f(A,B,C,D)arrow_forwardSuppose your computer is responding very slowly to information requests from the Internet. You observe that your network gateway shows high levels of network activity even though you have closed your e-mail client, Web browser, and all other programs that access the Internet. What types of malwares could cause such symptoms? What steps can you take to check whether malware has gained access to your system? What tools can you use at each step? If you identify malware, what ways might it have entered your system? How can you restore your PC to safe operation, including the special software tools you may use?arrow_forwardR languagearrow_forward
- Using R languagearrow_forwardCompare the security services provided by a digital signature (DS) with those of a message authentication code (MAC). Assume that Oscar can observe all messages sent between Rina and Naseem. Oscar has no knowledge of any keys but the public one, in the case of DS. State whether DS and MAC protect against each attack and, if they do, how. The value auth(x) is computed with a DS or a MAC algorithm. In each scenario, assume the message M = x#####auth(x). (Message integrity) Rina has the textual data x = “Transfer $1000 to Mark” to send to Naseem. To ensure the integrity of the data, Rina generates auth(x), forms a message M, and then sends M in cleartext to Naseem. Oscar intercepts the message and replaces “Mark” with “Oscar.” Will Naseem detect this in the case of either DS or MAC? If yes, how will Naseem detect it? If not, why? (Replay) Rina has the textual data x = “Transfer $1000 to Mark” to send to Naseem. To ensure the integrity of the data, Rina generates auth(x), forms a message…arrow_forwardI need to resolve the following....You are trying to convince your boss that your company needs to invest in a license for MS-Project (project management software from Microsoft) before beginning a systems project. What arguments would you give her?arrow_forward
- What are the four types of feasibility? what is the issues addressed by each feasibility component.arrow_forwardI would like to get ab example of a situation where Agile Methods might be preferable versus the traditional SDLC? What are the characteristics of this situation that give Agile Methods an advantage?arrow_forwardWhat is a functional decomposition diagram? what is a good example of a high level task being broken down into tasks in at least two lower levels (three levels in all).arrow_forward
- A Guide to SQLComputer ScienceISBN:9781111527273Author:Philip J. PrattPublisher:Course Technology PtrDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781285196145Author:Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos CoronelPublisher:Cengage LearningDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781305627482Author:Carlos Coronel, Steven MorrisPublisher:Cengage Learning
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningNp Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:Cengage




