
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
- In 32-bit MASM, Assume your grocery store sells three types of fruits. Apples, Oranges, and Mangos. Following are the sale numbers for the week (7 days).dataapples dword 42, 47, 52, 63, 74, 34, 73oranges dword 78, 53, 86, 26, 46, 51, 60mangos dword 30, 39, 41, 70, 75, 84, 29Using a single LOOP instruction, write a program to add elements in all these three arrays. Then assign the total result into the eax register. The eax register should have the value 1153 after a successful execution.arrow_forwardYou were given the following negative array. write a program that converts each array element to its positive representation. Then add all these array elements and assign them to the dl register. .data myarr sbyte -5, -6, -7, -4.code ; Write the rest of the program and paste the fully working code in the space below. The dl register should have the value 22 after summing up all elements in the array. Your answer must be in 32-bit MSAM.arrow_forwardImplementation of an Integrated Inventory Management System at Green Fields Manufacturing” Green Fields Manufacturing is a mid-sized company specialising in eco-friendly home and garden products. In recent years, growing demand has exposed the limitations of their fragmented processes and outdated systems. Different departments manage production schedules, raw material requirements, and finished goods inventory using a patchwork of spreadsheets and older software tools. These silos create inconsistent data, errors in stock levels, delivery delays, and customer dissatisfaction. Green Fields plans to implement an Integrated Inventory Management System to centralise production, procurement, inventory, and sales data to address these challenges. This technology aims to provide real-time visibility into stock levels, automate reorder points, and generate analytical dashboards for managers at both operational and strategic levels. Ultimately, the new system will streamline workflows, reduce…arrow_forward
- . Differentiate between continuous and discrete systems. How does their nature affect the selection of simulation techniques?arrow_forwardhi, I need help to resolve the case, thank youarrow_forwardThe following table shows the timestamp and actions by two users. Choose the best option that describes the outcome of the actions. Time JohnSara 10:14 select* from hr.employees; 10:15 Update hr.employees set salary= 100 where employee_id= 206; 10:16 Commit: Select* from hr.employees; 10:18 Commit: 10:20 Select* from hr.employees; Commit: John's query willreturn the same results all three times it is executed as they are run in the same session. John's queries run at10:16 and10:20 produce the same result, which is different from the one at 10:14 John's query run at 10:16 waits until 10:18 to produce results, waiting for the commit to happen. John's queries run at 10:14 and 10:16 produce the same result, which is different from the one at 10:20arrow_forward
- what's the process used to obtain IP configuration using DHCP in Windows Server.arrow_forwardConsider the following sequential circuit: CLOCK a. Define the diagram circuit variables (5 pts) b. Derive the Flip-Flop input equations) (5 pts) c. Derive the circuit output equation (5 pts) d. Derive the state table of the circuit (5 pts) e. Derive the state diagram for this circuit (5 pts) Clk A D B B' CIK Question 2 (25 pts) A sequential circuit with two D flip-flops A and B, two inputs x and y, and one output z is specified by the following next-state and output equations: A(t + 1) = xy' + xB B(t + 1) = xA + xB' z = A a. Draw the logic diagram of the circuit. (5 pts) b. List the state table for the sequential circuit. (10 pts) c. Draw the corresponding state diagram. (10 pts)arrow_forward5. Word FrequencyWrite a program that reads the contents of a text file. The program should create a dictio-nary in which the keys are the individual words found in the file and the values are the number of times each word appears. For example, if the word “the” appears 128 times, the dictionary would contain an element with 'the' as the key and 128 as the value. The program should either display the frequency of each word or create a second file containing a list of each word and its frequency.arrow_forward
- 3.) File Encryption and DecryptionWrite a program that uses a dictionary to assign “codes” to each letter of the alphabet. For example: codes = { ‘A’ : ‘%’, ‘a’ : ‘9’, ‘B’ : ‘@’, ‘b’ : ‘#’, etc . . .}Using this example, the letter A would be assigned the symbol %, the letter a would be assigned the number 9, the letter B would be assigned the symbol @, and so forth. The program should open a specified text file, read its contents, then use the dictionary to write an encrypted version of the file’s contents to a second file. Each character in the second file should contain the code for the corresponding character in the first file. Write a second program that opens an encrypted file and displays its decrypted contents on the screen.arrow_forwardReturns an US standard formatted phone number, in the format of (xxx) xxx-xxxx the AreaCode, Prefix and number being each part in order. Testing Hint: We be exact on the format of the number when testing this method. Make sure you think about how to convert 33 to 033 or numbers like that when setting your string format. Reminder the %02d - requires the length to be 2, with 0 padding at the front if a single digit number is passed in.arrow_forwardThe next problem concerns the following C code: /copy input string x to buf */ void foo (char *x) { char buf [8]; strcpy((char *) buf, x); } void callfoo() { } foo("ZYXWVUTSRQPONMLKJIHGFEDCBA"); Here is the corresponding machine code on a Linux/x86 machine: 0000000000400530 : 400530: 48 83 ec 18 sub $0x18,%rsp 400534: 48 89 fe mov %rdi, %rsi 400537: 48 89 e7 mov %rsp,%rdi 40053a: e8 d1 fe ff ff 40053f: 48 83 c4 18 add callq 400410 $0x18,%rsp 400543: c3 retq 0000000000400544 : 400544: 48 83 ec 08 sub $0x8,%rsp 400548: bf 00 06 40 00 mov $0x400600,%edi 40054d: e8 de ff ff ff callq 400530 400552: 48 83 c4 08 add $0x8,%rsp 400556: c3 This problem tests your understanding of the program stack. Here are some notes to help you work the problem: • strcpy(char *dst, char *src) copies the string at address src (including the terminating '\0' character) to address dst. It does not check the size of the destination buffer. You will need to know the hex values of the following characters: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




