The parts of this problem relate to the statement:
SELECT x
FROM T
WHERE y = 0
(a) The statement is used as the basis of the declaration of a cursor named Z. Assuming the
cursor is declared INSENSITIVE, what happens when it is opened?
(b) Give a FETCH statement that causes the value of x in a row of the result set to be placed
in host variable w.
(c) a KEYSET DRIVEN cursor. What happens when a KEYSET DRIVEN cursor is opened?
Describe a situation in which such a cursor behaves dierently then the cursor of (a).
(d) Suppose y is a key and we wish to execute the statement using static SQL without declaring
a cursor. As before, the value of x is to be placed in host variable w. Give the static
SQL statement.
e) Suppose the SELECT statement is constructed at run time and stored in host variable v
(of type string). As before, y is a key, the value of x is to be placed in w, and no cursor is
to be used. Give the dynamic SQL statements that cause this to happen
(f) The reference to w is handled dierently in static and dynamic SQL (parts (2d) and (2e)).
Explain why.
(a) The statement is used as the basis of the declaration of a cursor named Z. Assuming the
cursor is declared INSENSITIVE, what happens when it is opened?
Solution:
result set is calculated; cursor positioned to (one position before) the rst element
(b) Give a FETCH statement that causes the value of x in a row of the result set to be placed
in host variable w.
Solution:
FETCH x INTO :w
c) a KEYSET DRIVEN cursor. What happens when a KEYSET DRIVEN cursor is opened?
Describe a situation in which such a cursor behaves dierently then the cursor of (a).
Solution:
A table containing pointers (keys) to the rows of T satisfying the cursor's WHERE clause
is created.
A change to a row of T satisfying the cursor's WHERE clause that is made subsequent
to opening the cursor will be seen when the row is fetched. This is not true with an
INSENSITIVE cursor
(d) Suppose y is a key and we wish to execute the statement using static SQL without declaring
a cursor. As before, the value of x is to be placed in host variable w. Give the static
SQL statement.
Solution:
EXEC SQL SELECT x
INTO :w
FROM T
WHERE y=0
(e) Suppose the SELECT statement is constructed at run time and stored in host variable v
(of type string). As before, y is a key, the value of x is to be placed in w, and no cursor is
to be used. Give the dynamic SQL statements that cause this to happen.
Solution:
EXEC SQL PREPARE S FROM :v
EXEC SQL EXECUTE S INTO :w
(f) The reference to w is handled dierently in static and dynamic SQL (parts (2d) and (2e)).
Explain why.
Solution:
With static SQL the SQL statement is available at compile time. Hence the code for
accessing w can be produced by the compiler.
With dynamic SQL the SQL statement is constructed at run time. If w were embedded
in the string v, w would not be known at compile time and hence the compiler could not
construct code to access it. Placing w in the EXECUTE statement makes it available to
the compiler.
You might also like to view...
Which of the following statements is false?
a. For certain types of projects, NetBeans automatically includes JPA support, but not for simple Java Application projects. b. NetBeans projects do not include database drivers by default. c. Each Java Enterprise Edition (Java EE) API—such as JPA—has a reference im-plementation that you can use to experiment with the API’s features and implement applications. d. The JPA reference implementation—which is included with the NetBeans Java EE version—is NetBeansLink.
The Control panel is located ____.
A. beneath the Tool bar and directly above the document window B. beneath the Menu bar and directly above the horizontal ruler C. beneath the document tab and directly above the vertical ruler D. none of the above
Class styles have a ____ directly before the name.
A. forward slash B. backward slash C. period D. colon
The ________ action button automatically moves to the last slide in a slide show
Fill in the blank(s) with correct word