Database Final

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Assume the lastName value is obtained from a submitted form. Which values should replace XXX and YYY in the PHP code? $sql = "INSERT INTO Teacher (LastName) " . "VALUES (XXX)"; $stmt = $pdo->prepare($sql); $stmt->bindValue(YYY, $_POST["lastName"]); $stmt->execute(); a. :lastName , "lastName" b. :lastName, @lastName c. :lastName, :lastName d. $_lastName, $_lastName

a. :lastName , "lastName"

Which statement replaces XXX and YYY in the PHP code to call the stored procedure below? CREATE PROCEDURE GetTeacherLoad(IN teachID INT(6), OUT teacherLoadCount INT) ... $stmt = $pdo->prepare("CALL GetTeacherLoad(XXX, YYY)"); $stmt->bindValue(1, 32461); $stmt->execute(); $stmt = $pdo->query("SELECT @teacherLoadCount AS count"); $row = $stmt->fetch(); echo "Teacher Load Count for 32461 is $row[count]"; a. ?, @teacherLoadCount b. :teacherID, :teacherLoadCount c. "teacherId", "teacherLoadCount" d. ? , ?

a. ?, @teacherLoadCount

Which statements should replace XXX and YYY to execute the SELECT statement when the teacherID value is valid? CREATE PROCEDURE TeacherClassLoad(IN teachID INT) BEGIN DECLARE numberOfClasses INT; XXX SELECT COUNT(*) INTO numberOfClasses FROM Class WHERE TeacherID = teachID; YYY; END; a. IF teachID IS NOT NULL THEN, END IF b. IF teachID IS NOT NULL, END IF c. WHILE teachID IS NOT NULL DO, END WHILE d. WHILE teachID IS NOT NULL, END WHILE

a. IF teachID IS NOT NULL THEN, END IF

When using the fetch() in a SELECT statement, each call to fetch() returns the next row from the result table. If it reaches the last row, the next returned value is _____. a. NULL b. false c. LAST_ROW_VALUE d. true

b. false

The PHP code below throws an exception at line _____. 1. $sql = "INSERT INTO Teacher " . 2. "(LastName, FirstName, Department) " . 3. "VALUES (?, ?, ?)"; 4. 5. $stmt = $pdo->prepare($sql); 6. $stmt->bindValue(1, $_POST["lastName"]); 7. $stmt->bindValue(2, $_POST["firstName"]); 8. $stmt->execute(); 9. 10. echo "Teacher is added."; a. 1 b. 5 c. 8 d. 10

c. 8

Refer to the stored procedure. What is the correct call syntax to get the number of classes taught by Maggie Wilson with ID - 45631 through a stored procedure call from the command line? CREATE PROCEDURE TeacherClassLoad(IN teachID INT, OUT numberOfClasses INT) SELECT COUNT(*) INTO numberOfClasses FROM Class WHERE TeacherID = teachID; a. CALL TeacherClassLoad(45631, numberofClasses) b. CALL TeacherClassLoad("45631", @numberofClasses) c. CALL TeacherClassLoad("45631", "numberofClasses") d. CALL TeacherClassLoad(45631, @numberofClasses)

d. CALL TeacherClassLoad(45631, @numberofClasses)

Which statement should replace XXX? CREATE FUNCTION GetTeacherID(teacherLastName VARCHAR(20)) RETURNS INT XXX BEGIN DECLARE t_id INT; SELECT TeacherID INTO t_id FROM Teacher WHERE LastName = teacherLastName; END; a. SQL b. NO SQL c. DETERMINISTIC d. READS SQL DATA

d. READS SQL DATA


Kaugnay na mga set ng pag-aaral

Unit 4 (Hiemler) (Still 1450-1750)

View Set

Abeka 9th grade World Geography Chapter 2 Section 7 Review

View Set

Chapter 38: Caring for Clients With Cerebrovascular Disorders

View Set

Characteristics of Bacterial Cells

View Set

Networking CH. 1-6 preparation for midterm

View Set