Vous êtes sur la page 1sur 3

DB2 UDB 703 - Test Sample Thread 2: INSERT INTO mytab VALUES (4)

Thread 1: COMMIT
1. Which of the following static SQL statements can use a host
variable? Assuming that AUTOCOMMIT is ON, how many records will be
successfully inserted into the table MYTAB?
A. FETCH
B. ROLLBACK A. 1
C. DROP INDEX B. 2
D. ALTER TABLE C. 3
D. 4
2. Which of the following JDBC interfaces contains methods that
are called to determine whether or not cursors persist across 8. Given a table that has columns defined:
COMMIT boundaries? SMALLINT_COLUMN SMALLINT NOT NULL
VARCHAR_COLUMN VARCHAR(20)
A. ResultSet
B. Statement Which of the following statements is used to retrieve rows from the
C. DatabaseMetaData table and allows the second column to be checked for NULL
D. ResultSetMetaData values?

3. Which of the following JDBC objects can be used to determine A. FETCH * INTO :hv1, :hv2
the SQLSTATE if execution of a query fails? B. FETCH CURSOR1 INTO :hv1, :hv2
C. FETCH * INTO :hv1, :hv2 :hv2ind
A. Statement D. FETCH CURSOR1 INTO :hv1, :hv2 :hv2ind
B. ResultSet
C. SQLException 9. Given the following TWO SQL stored procedures:
D. ResultSetMetaData Procedure 1:
CREATE PROCEDURE myStorproc(p1 int, p2 char)
4. Which of the following can be used to access a DB2 database language sql
from a workstation that does not have any DB2 code installed? specific spintchar
BEGIN
A. Trigger IF ( P1 = 0 OR P1 = 1 ) THEN UPDATE DUMMY SET COL1 =
B. Java Applet INT(P2);
C. SQL Routines END IF ;
D. External Stored Procedure END
Procedure 2:
5. Which of the following programming interfaces can be used to CREATE PROCEDURE myStorproc(p1 int)
program static queries from a Java application? language sql
specific spint
A. CLI BEGIN
B. JTA IF ( P1 = 0 OR P1 = 1 ) THEN UPDATE DUMMY SET COL1 =
C. JDBC P1 ;
D. SQLJ END IF ;
E. OLEDB END

6. Given a cursor C1 on table T1. For every row fetched from T1, Which of the following statements will remove Procedure 1 from
open a cursor C2 on table T2. For every row fetched from T2, the database?
update column C1 in table T2 and issue a COMMIT.
A. DROP PROCEDURE myStorproc (p1, p2)
Which of the following must define cursor C1? B. DROP PROCEDURE myStorproc (int, char)
C. DROP SPECIFIC PROCEDURE spintchar (p1, p2)
A. DECLARE c1 CURSOR WITH HOLD FOR SELECT * FROM D. DROP SPECIFIC PROCEDURE spintchar (int, char)
t1 E. DROP SPECIFIC PROCEDURE myStorproc (int, char)
B. DECLARE c1 CURSOR WITH RETURN FOR SELECT *
FROM t1 10. During which of the following are SQL statements optimized
when using DB2 CLI?
C. DECLARE c1 CURSOR FOR SELECT * FROM t1 FOR
UPDATE OF t2 A. cursor open
D. DECLARE c1 CURSOR FOR SELECT * FROM t1 FOR B. precompile phase
UPDATE OF c1 C. application binding
D. statement preparation

7. Given an ODBC/CLI program with a single connection, two 11. Given the following table and trigger definition:
threads and the following actions:
TABLE: DEPTINFO
Thread 1: INSERT INTO mytab VALUES (1) DeptID DeptTitle DeptCount
Thread 2: INSERT INTO mytab VALUES (2) ====== ========= =========
Thread 1: INSERT INTO mytab VALUES (3) 1 SALES 5
Thread 1: ROLLBACK 2 MKTG 2
3 DEVELOPMENT 17
(check error information in SQLCA)
CREATE TRIGGER notify (Cleanup)
AFTER UPDATE OF deptid,deptcount ON deptinfo
REFERENCING OLD AS o NEW AS n End Program
FOR EACH ROW DB2SQL MODE
WHEN(o.DeptCount=0 OR n.DeptId<4) What table will be updated in "samplea" if the second DELETE
BEGIN completes successfully?
INSERT INTO notifylog VALUES(CURRENT
TIMESTAMP,'Check on Dept Changes'); A. usera.tablex
END B. userb.tablea
C. usera.tablea
How many rows will be inserted into the NOTIFYLOG table as a D. userb.tablex
result of the trigger activations caused by the successful execution
of the following set of SQL statements?
13. Which of the following ODBC/CLI statement handle attributes
UPDATE DeptInfo SET DeptCount = DeptCount+1 permits an application to change the memory address of all bound
UPDATE DeptInfo SET DeptTitle = 'MARKETING' WHERE parameter markers without making any ODBC/CLI API calls?
DeptId=2
UPDATE DeptInfo SET DeptCount = 10 WHERE DeptID=1 A. SQL_ATTR_PARAM_BIND_TYPE
B. SQL_ATTR_PARAM_STATUS_PTR
A. 2 C. SQL_ATTR_PARAM_OPERATION_PTR
B. 3 D. SQL_ATTR_PARAM_BIND_OFFSET_PTR
C. 4
D. 5 14. Given a table created using the statement:
CREATE TABLE abc.stuff (i INT)

12. Given the following embedded SQL pseudocode: A user called XYZ is to be enabled to access data from table
Start Program ABC.STUFF using an implicit schema.
EXEC SQL BEGIN DECLARE SECTION
USERA CHARACTER (8) Assuming the necessary privileges have been granted, which of the
USERB CHARACTER (8) following statements issued by user ABC will provide this result?
PW CHARACTER (8)
COLVAL CHARACTER (16) A. CREATE ALIAS stuff FOR abc.stuff
EXEC SQL END DECLARE SECTION B. CREATE VIEW abc.stuff FOR xyz.stuff
C. CREATE ALIAS abc.stuff FOR xyz.stuff
EXEC SQL INCLUDE SQLCA D. CREATE VIEW xyz.stuff AS SELECT i FROM abc.stuff
EXEC SQL WHENEVER SQLERROR GOTO ERRCHK

(program logic) 15. Which of the following is required to successfully execute a


(:usera contains the string "usera") DB2 Call Level Interface (CLI) application?
( wa contains a valid password)
(:userb now contains the string "userb") A. The user must have EXECUTE privilege on the application.
( wb contains a valid password) B. The developer must have EXECUTE privilege on the
application.
EXEC SQL CONNECT TO samplea USER :usera USING wa C. The user must have sufficient privileges on referenced tables.
EXEC SQL SELECT col1, col2 FROM tablea D. The developer must have sufficient privileges on referenced
tables.
(program logic to retrieve results)
16. USERA has authority to access all tables in a database. Which
EXEC SQL COMMIT DB2 application development interface should be used to restrict
USERA from accessing tables with payroll information during
(more program logic) application runtime?

EXEC SQL CONNECT TO sampleb USER :userb USING wb A. CLI


EXEC SQL SELECT col1, col2 FROM tablex B. JDBC
EXEC SQL DELETE FROM tablea WHERE col1= :colval //1st C. Embedded static SQL
delete D. Embedded dynamic SQL
EXEC SQL COMMIT
17. Given the following:
(more program logic) EXEC SQL BEGIN DECLARE SECTION;
char var1[20];
EXEC SQL SET CONNECTION samplea short var2;
EXEC SQL DELETE from tablea where col1= :colval //2nd delete EXEC SQL END DECLARE SECTION;
EXEC SQL COMMIT
Which two of the following examples correctly demonstrate the use
EXEC SQL CONNECT RESET of host variables within an SQL statement?
ERRCHK
Connection con = DriverManager.getConnection(url);
(Choose 2) DefaultContext ctx = new DefaultContext(con);
DefaultContext.setDefaultContext(ctx);
A. EXEC SQL CONNECT TO var1 If an UPDATE statement is issued using the ctx context, which of
B. EXEC SQL FETCH c1 INTO :var1 :var2 the following SQLJ methods should be used to obtain the number
C. EXEC SQL UPDATE name_column INTO :var1 of rows modified by the UPDATE statement?
D. EXEC SQL SELECT name_column INTO :var1 FROM T1
E. EXEC SQL SELECT name_column INTO :var1, :var2 FROM A. ctx.rowsUpdated()
T1 B. ctx.SQLRowCount()
C. ctx.getUpdateCount()
18. Given that any referenced database objects exist and all host D. con.getUpdateCount()
variables have been declared appropriately.
23. An SQLJ application needs to connect to a remote data source
Which two of the following lines of embedded SQL code can be SAMPLE using a userid and password. Which of the following will
successfully precompiled into the appropriate host-language establish the connection?
source?
A. #sql con={CONNECT TO SAMPLE :userid assword
(Choose 2) B. getConnection("jdbc b2:SAMPLE",userid,password)
C. getConnection("jdbc b2:SAMPLE:userid assword")
A. EXEC SQL FETCH c1 INTO :var1 :var2 :var3; D. #sql con={CONNECT TO SAMPLE USER :userid USING
B. #sql iter = { SELECT col1 FROM tab1 WHERE col2=:var1 ; assword
C. SQL UPDATE tab1 SET col1 = :var1 :var2 WHERE col2 =
:var3; 24. Which of the following CLI/ODBC functions will return the
D. #sql exec { SELECT col1, col2 FROM tab1 WHERE col2 = number of rows affected by an INSERT, UPDATE or a DELETE
:var1 ; statement?
E. EXEC SQL OPEN c1; if (SQLCODE >= 0) EXEC SQL FETCH
c1 INTO :var1 :var2; A. SQLNumRows()
B. SQLRowCount()
19. Which of the following is a required parameter for running C. SQLRowsChanged()
db2profc? D. SQLUpdateCount()

A. userid 25. Given the SQL statement:


B. server name WITH management (name,totalpay,department,location) AS
C. prep options (
D. profile name SELECT a.name, (a.salary * :bonusrate), b.deptname, b.location
FROM staff a, org b
20. Assume that the following SQL statements have been WHERE a.dept=b.deptnumb AND a.job='Mgr'
successfully issued: )
CONNECT TO db1 USER user1 USING pw1 SELECT * FROM management WHERE totalpay > :threshold
DECLARE GLOBAL TEMPORARY TABLE temp1 (val
INTEGER) ... Which of the following is the above an example of?

Which of the following statements will successfully insert a row A. Derived view
into the temporary table TEMP1? B. Derived table
C. Scalar subselect
A. INSERT INTO db1.temp1 VALUES (100) D. Common table expression
B. INSERT INTO user1.temp1 VALUES (100)
C. INSERT INTO session.temp1 VALUES (100)
D. INSERT INTO temporary.temp1 VALUES (100) 26. Which of the following must be used by an application to
retrieve multiple rows?
21. Given the following table:
CREATE TABLE employee A. SQLCA
(name CHAR(10), salary DEC) B. CURSOR
INSERT INTO employee (name, salary) VALUES ('SMITH', C. SELECT INTO statement
30000) D. COMPOUND SQL statement
INSERT INTO employee (name) VALUES ('JONES')
INSERT INTO employee (name, salary) VALUES ('ALI', 35000)

Which of the following statements will retrieve the lowest


computed value?

A. SELECT SUM(SALARY)/COUNT(*) FROM EMPLOYEE


B. SELECT MIN(SALARY) FROM EMPLOYEE
C. SELECT AVG(SALARY) FROM EMPLOYEE
D. SELECT SUM(SALARY) FROM EMPLOYEE

22. Given the following code from an SQLJ source file:

Vous aimerez peut-être aussi