Mid Paper Pattern CS405 - Mid
Mid Paper Pattern CS405 - Mid
MCQs
Take an assessment.
Question#1
What is the purpose of using a cursor in SQL?
A) To process each row of a result set one at a time.
B) To fetch multiple rows at once.
C) To store the result set in memory.
D) To update the database.
Question#2
What is the syntax to declare a cursor in SQL?
A) DECLARE cursor_name CURSOR
B) CREATE cursor_name CURSOR
C) SET cursor_name CURSOR
D) DEFINE cursor_name CURSOR
Question#3
What is the purpose of the SQL SELECT statement?
A) To retrieve data from one or more tables in a database.
B) To update data in a database.
C) To delete data from a database.
D) To create a new database.
Question#4
What does an implicit cursor do in PL/SQL?
a) Executes the query and retrieves data one row at a time
b) Executes the query and retrieves all data at once
c) Processes the data after it has been retrieved
d) None of the above
Question#5
How do you process data using an implicit cursor in PL/SQL?
a) By using the FETCH statement to retrieve each row of data one at a time
b) By using the SELECT statement to retrieve all data at once
c) By using the INSERT statement to store data in the database
d) None of the above
Question#6
What is the syntax for an implicit cursor in PL/SQL?
a) SELECT ... INTO ...
b) FETCH ... INTO ...
c) INSERT ... INTO ...
d) None of the above
Question#7
What is the syntax for declaring an explicit cursor in SQL?
a. DECLARE cursor_name CURSOR;
b. DECLARE cursor_name FOR SELECT;
c. DECLARE cursor_name SELECT;
d. DECLARE cursor_name CURSOR FOR SELECT;
Question#8
What is the purpose of a FOR loop when processing an explicit cursor in SQL?
a. To retrieve and process each row of the result set one at a time
b. To retrieve and process the entire result set at once
c. To specify the number of times the loop should be executed
d. To reverse the order of the rows in the result set
Question#9
What is the syntax for opening an explicit cursor in SQL?
a. OPEN cursor_name;
b. START cursor_name;
c. BEGIN cursor_name;
d. INIT cursor_name;
Question#10
What is the syntax for fetching the next row from an explicit cursor in SQL?
a. GET NEXT FROM cursor_name;
b. FETCH NEXT FROM cursor_name;
c. READ NEXT FROM cursor_name;
d. SELECT NEXT FROM cursor_name;
Question#11
How do you sort a result set in SQL?
a) By using the ORDER BY clause
b) By using the GROUP BY clause
c) By using the WHERE clause
d) None of the mentioned
Question#12
What is the purpose of the INNER JOIN in SQL?
a) To combine rows from two or more tables based on a related column between them
b) To return only the rows from one table where there is no match in the other table
c) To return all the rows from both tables, including the unmatched ones.
d) None of the mentioned
Question#13
How do you add a new row to a PL/SQL table?
A) INSERT INTO table_name (attribute1, attribute2, ...) VALUES (value1, value2, ...);
B) ADD ROW TO table_name (attribute1, attribute2, ...) VALUES (value1, value2, ...);
C) ADD NEW ROW TO table_name (attribute1, attribute2, ...) VALUES (value1, value2, ...);
D) INSERT INTO table_name SET attribute1 = value1, attribute2 = value2, ...;
Question#14
How do you retrieve data from a PL/SQL table?
A) SELECT * FROM table_name;
B) RETRIEVE ALL FROM table_name;
C) FETCH ALL FROM table_name;
D) SELECT ALL FROM table_name;
Question#15
How do you update a specific row in a PL/SQL table?
A) UPDATE table_name SET attribute1 = value1, attribute2 = value2, ... WHERE condition;
B) CHANGE ROW IN table_name SET attribute1 = value1, attribute2 = value2, ... WHERE condition;
C) MODIFY ROW IN table_name SET attribute1 = value1, attribute2 = value2, ... WHERE condition;
D) UPDATE ROW IN table_name SET attribute1 = value1, attribute2 = value2, ... WHERE condition;
Question#16
What type of data structure can be used to store a collection of records in PL/SQL?
A. Arrays
B. Associative arrays (index-by tables)
C. Nested tables
D. Varrays
Question#17
What is the syntax for declaring a PL/SQL table with a record type in SQL?
A. CREATE TABLE table_name OF record_type_name
B. DECLARE TABLE table_name AS record_type_name
C. CREATE INDEX-BY TABLE table_name OF record_type_name
D. DECLARE INDEX-BY TABLE table_name AS record_type_name
Question#18
What is the purpose of the COLLECT clause in SQL?
A. To retrieve data from a PL/SQL table
B. To insert data into a PL/SQL table
C. To aggregate data in a PL/SQL table
D. To sort data in a PL/SQL table
Question#19
What is the purpose of the FORALL statement in PL/SQL?
A. To retrieve data from a PL/SQL table
B. To insert data into a PL/SQL table
C. To update data in a PL/SQL table
D. To delete data from a PL/SQL table
Question#20
What type of parameter is used to pass a value from a calling program to a stored procedure or function
in PL/SQL?
a. IN
b. OUT
c. INOUT
d. Both a and b
Question#21
What type of parameter is used to return a value from a stored procedure or function to a calling
program in PL/SQL?
a. IN
b. OUT
c. INOUT
d. Both a and b
Question#22
What type of parameter is used to pass values in both directions, from a calling program to a stored
procedure or function and vice versa in PL/SQL?
a. IN
b. OUT
c. INOUT
d. Both a and b
Question#23
How is the value of an OUT parameter set in a stored procedure in PL/SQL?
a. By using the RETURN statement
b. By using the OUT parameter_name := value; statement
c. By using the INOUT parameter_name := value; statement
d. Both a and b
Question#24
What is the syntax to call a stored procedure with IN/OUT parameters in PL/SQL?
a. EXECUTE procedure_name (IN parameter1, OUT parameter2);
b. CALL procedure_name (IN parameter1, OUT parameter2);
c. EXEC procedure_name (IN parameter1, OUT parameter2);
d. Both a and b
Question#25
What keyword is used to specify the data type of the value returned by a PL/SQL function?
A. RETURNS
B. RETURN
C. OUTPUT
D. RETURN_TYPE
Question#26
Can a PL/SQL function have multiple parameters?
A. No
B. Yes, but only if they are of the same data type
C. Yes, but the number of parameters is limited to five
D. Yes, a PL/SQL function can have any number of parameters of any data type
Question#27
What is the purpose of the BEGIN and END keywords in a PL/SQL function?
A. To declare the start and end of a PL/SQL block
B. To define the data type of the parameters passed to the function
C. To specify the name of the function and the data type of the return value
D. To declare the local variables used within the function
What will this code produce the output when run in a PL/SQL environment?
Question#2
What is the syntax for creating a PL/SQL procedure in Oracle?
Question#3
What is the syntax for implementing a PL/SQL procedure with multiple return values?
Subjective Questions (5 Marks)
Question#1
Explain the difference between a procedure and a function in PL/SQL.
Question#2
Explain the purpose of PL/SQL exceptions and how to handle them.
Question#3
What is a trigger in PL/SQL and how does it work?