
Concept explainers
a.
Stored procedures:
- A procedure is a collection of procedural and SQL statements.
- A procedure may have input parameter or output parameter or sometimes both the parameters.
- It is declared with a unique name 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_OWNER (I_OWNER_NUM IN OWNER.OWNER_NUM%TYPE) AS
I_FIRST_NAME OWNER.FIRST_NAME%TYPE;
I_LAST_NAME OWNER.LAST_NAME%TYPE;
BEGIN
SELECT FIRST_NAME, LAST_NAME
INTO I_FIRST_NAME, I_LAST_NAME
FROM OWNER
WHERE OWNER_NUM = I_OWNER_NUM;
DBMS_OUTPUT.PUT_LINE(I_OWNER_NUM);
DBMS_OUTPUT.PUT_LINE(I_FIRST_NAME);
DBMS_OUTPUT.PUT_LINE(I_LAST_NAME);
END;
/
Explanation:
- The above query is used to create a procedure named “DISP_OWNER” to select the records in the “OWNER” table.
- Change the “OWNER_NUM” into “I_OWNER_NUM” and place the “FIRST_NAME” and “LAST_NAME” values into “I_FIRST_NAME” and “I_LAST_NAME”.
- After placing these values, display the “I_OWNER_NUM”, “I_FIRST_NAME”, and “I_LAST_NAME” from the “OWNER” table.
- Once the stored procedure is created, it needs to be executed.
Query to view the owner name and ID:
BEGIN
DISP_OWNER ('AN175');
END;
The above query is used to view the owner ID, first name, and last name for the number “AN175”.
Output:
AN175
Bill
Anderson
Explanation of Solution
b.
Query to create stored procedure:
CREATE OR REPLACE PROCEDURE DISP_CONDO_UNIT
(I_CONDO_ID IN CONDO_UNIT.CONDO_ID%TYPE) AS
I_LOCATION_NUM CONDO_UNIT.LOCATION_NUM%TYPE;
I_UNIT_NUM CONDO_UNIT.UNIT_NUM%TYPE;
I_OWNER_NUM CONDO_UNIT.OWNER_NUM%TYPE;
I_FIRST_NAME OWNER.FIRST_NAME%TYPE;
I_LAST_NAME OWNER.LAST_NAME%TYPE;
BEGIN
SELECT LOCATION_NUM, UNIT_NUM, CONDO_UNIT.OWNER_NUM, FIRST_NAME, LAST_NAME
INTO I_LOCATION_NUM, I_UNIT_NUM, I_OWNER_NUM, I_FIRST_NAME, I_LAST_NAME
FROM CONDO_UNIT, OWNER
WHERE CONDO_UNIT.OWNER_NUM = OWNER.OWNER_NUM
AND CONDO_ID = I_CONDO_ID;
DBMS_OUTPUT.PUT_LINE(I_CONDO_ID);
DBMS_OUTPUT.PUT_LINE(I_LOCATION_NUM);
DBMS_OUTPUT.PUT_LINE(I_UNIT_NUM);
DBMS_OUTPUT.PUT_LINE(I_OWNER_NUM);
DBMS_OUTPUT.PUT_LINE(I_FIRST_NAME);
DBMS_OUTPUT.PUT_LINE(I_LAST_NAME);
END;
/
Explanation:
- The above query is used to create a procedure named “DISP_CONDO_UNIT” to select the records in the “CONDO_UNIT” and “OWNER” tables.
- Change the “CONDO_ID” into “I_CONDO_ID” and place the “LOCATION_NUM”, “UNIT_NUM”, “OWNER_NUM”, “FIRST_NAME”, and “LAST_NAME” values into “I_LOCATION_NUM”, “I_UNIT_NUM”, “I_OWNER_NUM”, “I_FIRST_NAME”, and “I_ LAST_NAME”.
- After placing these values, display the “I_CONDO_ID”, I_LOCATION_NUM”, “I_UNIT_NUM”, “I_OWNER_NUM”, “I_FIRST_NAME”, and “I_ LAST_NAME” from the “CONDO_UNIT” and “OWNER” tables.
- Once the stored procedure is created, it needs to be executed.
Query to view a result:
BEGIN
DISP_CONDO_UNIT(3);
END;
The above query is used to view the condo Id, location number, unit number, owner number, first name and last name for the condo id “3”.

Output:
3
1
306
AN175
Bill
Anderson
Explanation of Solution
c.
Query to insert the value:
CREATE OR REPLACE PROCEDURE ADD_OWNER
(I_OWNER_NUM IN OWNER.OWNER_NUM%TYPE,
I_LAST_NAME IN OWNER.LAST_NAME%TYPE,
I_FIRST_NAME IN OWNER.FIRST_NAME%TYPE,
I_ADDRESS IN OWNER.ADDRESS%TYPE,
I_CITY IN OWNER.CITY%TYPE,
I_STATE IN OWNER.STATE%TYPE,
I_POSTAL_CODE IN OWNER.POSTAL_CODE%TYPE) AS
BEGIN
INSERT INTO OWNER (OWNER_NUM, LAST_NAME, FIRST_NAME, ADDRESS, CITY, STATE, POSTAL_CODE)
VALUES
(I_OWNER_NUM, I_LAST_NAME, I_FIRST_NAME, I_ADDRESS, I_CITY, I_STATE,
I_POSTAL_CODE);
END;
/
Explanation:
The above query is used to create a stored procedure named “ADD_OWNER” to insert the new record in the “OWNER” table. Once the stored procedure is created, it needs to be executed.
Query to execute the stored procedure:
BEGIN
ADD_OWNER ('AZ245', 'William', 'John', '125 North St.', 'Mills', 'SC', 29707);
END;
After executing the above query, the new record is inserted into the table “OWNER”.

Output:
Query to view the contents in “OWNER” table is as follows:
SELECT * FROM OWNER;
Screenshot of output
Explanation of Solution
d.
Query to update stored procedure:
CREATE OR REPLACE PROCEDURE CHG_OWNER
(I_OWNER_NUM IN OWNER.OWNER_NUM%TYPE,
I_LAST_NAME IN OWNER.LAST_NAME%TYPE) AS
BEGIN
UPDATE OWNER
SET LAST_NAME = I_LAST_NAME
WHERE OWNER_NUM = I_OWNER_NUM;
END;
/
Explanation:
The above query is used to create a stored procedure named “CHG_OWNER” to update the last name of the owner whose number is stored in “I_OWNER_NUM” to the value presently found in “I_OWNER_NUM”, it needs to be executed.
Query to execute the stored procedure:
BEGIN
CHG_OWNER ('AZ245', 'Andrew');
END;
After executing the above query, the last name is changed in the table “OWNER”.

Output:
Query to view the contents in “OWNER” table is as follows:
SELECT * FROM OWNER;
Screenshot of output
Explanation of Solution
e.
Query to delete the value:
CREATE OR REPLACE PROCEDURE DELETE_OWNER
(I_OWNER_NUM IN OWNER.OWNER_NUM%TYPE) AS
BEGIN
DELETE
FROM OWNER
WHERE OWNER_NUM = I_OWNER_NUM;
END;
/
Explanation:
- The above query is used to create a procedure named “DELETE_OWNER” to delete a record in the “OWNER” table.
- Once the record is deleted, a procedure should create owner number as a parameter.
- Once the stored procedure is created, it needs to be executed.
Query to execute the stored procedure:
BEGIN
DELETE_OWNER ('AZ245');
END;
The above query is used to delete the order number AZ245.

Output:
Query to view the contents in “OWNER” table after deleting the order number AZ245 as follows:
SELECT * FROM OWNER;
Screenshot of output
Want to see more full solutions like this?
Chapter 8 Solutions
A Guide to SQL
- Ideal MOSFET Current–Voltage Characteristics—NMOS Device and draw the circuitarrow_forward1. Create a Person.java file. Implement the public Person and Student classes in Person.java, including all the variables and methods in the UMLS. Person -name: String -street: String -city: String +Person(String name, String, street, String, city) +getName(): String +setName(String name): void +getStreet(): String +setStreet(String street): void +getCity(): String +setCity(String City): void +toString(): String Student -Id: int +Person(String name, String, street, String, city, int Id) +getId(): int +setId(int Id): void +toString(): String 2. Create a StudentTest.java file. Implement a public StudentTest class with a main method. In the main method, create one student object and print the object using System.out.println(). Your printing result must follow the example output: name: Mike, street: Morris Ave, city: Union, Id: 1000 Hint: You need to modify the toString methods in the Student class and Person class!arrow_forward1) Apply the Paint Blue algorithm discussed in class to the following Finite Automata. a a a b b a COIS-3050H-R-W01-2025WI-COMB Formal Languages & Automata a b Show the status of the Finite Automata at the conclusion of the Paint Blue Algorithm (mark the visited states with an X and only include edges that have not been followed). 2) Use the pumping lemma to prove the following language is nonregular: L= {ab} = {abbb, aabbbbbb, aaabbbbbbbbb, ...}arrow_forward
- 3) Find CFGs that for these regular languages over the alphabet Σ= {a, b}. Draw a Finite Automata e CFG. 1 COIS-3050H-R-W01-2025WI-COMB Formal anguages & Automata Is that contain the substring aba. (b) The language of all words that have an odd number letters and contains the string bb. (c) The language of all words that begin with the substring ba and contains an odd number of letters. 4) Convert the following FA into a PDA. a a S± b a a Ν Ꮓarrow_forwardCOIS-3050H-R-W01-2025WI-COMB Formal ministic PDA. Are the following words accepted by this Languages & Automata UI MIUSɩ that aTU I ed, indicate which state the PDA is in when the crash occurs. (a) aabbaa (b) aaabab (c) bababa Start (d) aaaabb A Accept Read₁ Push a (e) aaaaaa a b Read, Popi a a,b A Read₂ Accept A Pop₂arrow_forward5) Eliminate the A-productions from the following CFG: Abc COIS-3050H-R-W01-2025WI-COMB Formal Languages & Automata BAabC C CaA | Bc | A 6) Convert the following CFG into CNF. S→ XYZ XaXbS | a |A YSbS | X | bb Z→ barrow_forward
- Need help answering these questions!1. Design a While loop that lets the user enter a number. The number should be multiplied by 10, and the result stored in a variable named product. The loop should iterate as long as the product contains a value less than 100. 2. Design a For loop that displays the following set of numbers: 0, 10, 20, 30, 40, 50 . . . 1000 3. Convert the While loop in the following code to a Do-While loop: Declare Integer x = 1 While x > 0 Display "Enter a number." Input x End Whilearrow_forwardNeed help with these:Design a While loop that lets the user enter a number. The number should be multiplied by 10, and the result stored in a variable named product. The loop should iterate as long as the product contains a value less than 100. 2. Design a For loop that displays the following set of numbers: 0, 10, 20, 30, 40, 50 . . . 1000 3. Convert the While loop in the following code to a Do-While loop: Declare Integer x = 1 While x > 0 Display "Enter a number." Input x End Whilearrow_forwardConvert the While loop in the following code to a Do-While loop: Declare Integer x = 1 While x > 0 Display "Enter a number." Input x End Whilearrow_forward
- Python - need help creating a python program that will sum the digits of a number entered by the user. For example if the user inputs the value 243 the program will output 9 because 2 + 4 + 3 = 9. The program should ask for a single integer from the user, it should then calculate the sum of all the digits of that number and output the result.arrow_forwardI need help with this in Python (with flowchart): Im creating a reverse guessing game. Then to choose a random number from 1 to 100 and the computer program will attempt to guess it, displaying the directions calculated or not. The guess will be displayed and the user will answer if it was correct or not. If correct, the game ends, if not then the computer asks if the guess was too high or too low. Finally inputting an answer and the computer generates a new guess within the proper range. Oh and to make sure the program doesnt guess outside of the ranges produced by the inputs of “too high” and “too low”. The program ending when the user guesses correctly or after the program takes 6 guesses. HELP ASAP!arrow_forwardI need help with this in Python (with flowchart): Im creating a reverse guessing game. Then to choose a random number from 1 to 100 and the computer program will attempt to guess it, displaying the directions calculated or not. The guess will be displayed and the user will answer if it was correct or not. If correct, the game ends, if not then the computer asks if the guess was too high or too low. Finally inputting an answer and the computer generates a new guess within the proper range. Oh and to make sure the program doesnt guess outside of the ranges produced by the inputs of “too high” and “too low”. The program ending when the user guesses correctly or after the program takes 6 guesses. HELP ASAP!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



