Font size
WorksheetsU3.4. CallableStatements (JDBC)
Total questions: 14
Worksheet time: 9mins
Which of the following statements about CallableStatement is true?
It is used to execute SQL queries directly without parameters.
It can call stored procedures in the database and accept parameters.
It is specifically for executing SELECT statements only.
It cannot handle parameters.
What type of SQL data modification is indicated by MODIFIES SQL DATA in a procedure declaration?
The procedure only reads data.
The procedure changes data in the database, such as with INSERT, UPDATE, or DELETE.
The procedure only creates temporary data.
The procedure does not alter any data.
Which of the following correctly declares a procedure in HSQLDB that only reads data?
CREATE PROCEDURE readOnlyProc() MODIFIES SQL DATA BEGIN ... END;
CREATE PROCEDURE readOnlyProc() READS SQL DATA BEGIN ... END;
CREATE PROCEDURE readOnlyProc() BEGIN READS SQL DATA ... END;
CREATE PROCEDURE readOnlyProc() READ DATA ONLY BEGIN ... END;
Given the following code snippet in Java, which line correctly registers an OUT parameter?
call.setOutParameter(2, Types.INTEGER);
call.registerOutParameter(1, Types.INTEGER);
call.registerOutParameter(2, Types.INTEGER);
call.getInt(2);
Which of the following is NOT true about OUT parameters in stored procedures?
They allow procedures to return values to the caller.
They must be declared as OUT in the procedure definition.
They are registered in Java using registerOutParameter.
They cannot be retrieved in Java after procedure execution.
What would the following SQL code do in the context of a departments table?
Changes the office field for all departments to the value of office_name.
Adds a new department with office set to office_name.
Deletes all entries in the departments table where office matches
Only modifies the office field if the department is INFORMATICA.
In Java, which method should you use to retrieve the result of an OUT parameter after executing a stored procedure?
call.setInt(index);
call.getXXX(index);
call.execute();
call.close();
Given this Java code, what value will departmentCount hold after execution?
The number of employees in each department.
The total number of departments.
The maximum department number.
The number of departments with a specific name.
If a stored procedure is declared with READS SQL DATA, what does it mean?
The procedure can only execute SELECT statements.
The procedure cannot modify data in the database.
The procedure must modify data in the database.
The procedure will always fail if it modifies data.
Consider the following SQL snippet. What does this stored procedure do?
Returns the total number of departments.
Sets n to the department number of the newest department.
Returns the next available department number by adding 1 to the maximum department number.
Sets n to 1 if there are no departments in the table.
Which SQL clause ensures that all statements within a procedure execute as a single transaction?
MODIFIES SQL DATA
BEGIN
ATOMIC
LIMIT 1
Which of the following correctly sets the name of the most veteran teacher to an OUT parameter veteran_name?
SET veteran_name = (SELECT name FROM teachers ORDER BY start_date DESC LIMIT 1);
SET veteran_name = (SELECT name FROM teachers WHERE start_date IS NOT NULL ORDER BY start_date ASC LIMIT 1);
SET veteran_name = (SELECT name FROM teachers WHERE start_date ORDER BY ASC LIMIT 1);
SET veteran_name = (SELECT name FROM teachers LIMIT 1);
What do you think is the most important concept of the content covered in this unit?
You can only use 1-2 words.
From 1 to 5, how confident do you feel with the topic covered in this unit?
1 - not confident at all
2 - slightly confident
3 - moderately confident
4 - very confident
5 - extremely confident
