You are on page 1of 49

Exam : 000-703

Title : DB2 UDB V8.1 Family Application Development


Ver
: 06-12-07
000-703
QUESTION 1:
Given the following code:
EXEC SQL EXECUTE IMMEDIATE :sqlstmt
Which of the following values must sqlstmt contain so that all rows are deleted from
the STAFF table?
A. DROP TABLE staff
B. DELETE FROM staff
C. DROP * FROM staff
D. DELETE * FROM staff
Answer: B
QUESTION 2:
Given the code:
EXEC SQL DECLARE cursor1 CURSOR FOR
SELECT name,age,b_date FROM person;
EXEC SQL OPEN cursor1;
Under which of the following situations will the above cursor be implicitly closed?
A. When a CLOSE statement is issued
B. When a COMMIT statement is issued
C. When there are no rows in the result set
D. When all rows are FETCHed from the result set
Answer: B
QUESTION 3:
To prepare an embedded SQL program for use with a host-language compiler,
which of the following database components is required?
A. Binder
B. Precompiler
C. Stored Procedure Builder
D. Application Development Center
Answer: B
QUESTION 4:
An ODBC/CLI application has the following pseudocode:
SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc )
Actualtests.com - The Power of Knowing
000-703
SQLConnect( hDbc, "CERTDB", SQL_NTS, "user1", SQL_NTS, "passwd", SQL_NTS )
SQLAllocHandle( SQL_HANDLE_STMT, hDbc, &hStmt )
SQLExecDirect( hStmt, "SET CURRENT SQLID db2cert", SQL_NTS )
Assuming all of the above calls execute successfully, which of the following fully
qualified SQL statements is equivalent to:
SQLExecDirect( hStmt, "SELECT * FROM user1.table1 t1, table2 t2 WHERE
t1.col1=t2.col2", SQL_NTS )
A. SQLExecDirect( hStmt, "SELECT * FROM user1.table1 t1, table2 t2 WHERE
t1.col1=t2.col2", SQL_NTS )
B. SQLExecDirect( hStmt, "SELECT * FROM user1.table1 t1, user1.table2 t2 WHERE
t1.col1=t2.col2", SQL_NTS )
C. SQLExecDirect( hStmt, "SELECT * FROM user1.table1 t1, db2cert.table2 t2
WHERE t1.col1=t2.col2", SQL_NTS )
D. SQLExecDirect( hStmt, "SELECT * FROM db2cert.table1 t1, db2cert.table2 t2
WHERE t1.col1=t2.col2", SQL_NTS )
Answer: C
QUESTION 5:
Given the EMPLOYEE table definition:
CREATE TABLE employee (
workdept CHAR(30),
salary INTEGER
)
Which of the following is a correct usage of parameter markers in a JDBC
program?
A. String sql =
"UPDATE employee SET salary=salary*?WHERE workdept=?";
statement stmt=con.createStatement(sql);
B. String sql =
"UPDATE employee SET salary=salary*?WHERE workdept=?";
statement stmt=con.createStatement(sql);
C. String sql =
"UPDATE employee SET salary=salary*?WHERE workdept=?";
statement stmt=con.createStatement(sql);
D. String sql =
"UPDATE employee SET salary=salary*?WHERE workdept=?";
statement stmt=con.createStatement(sql);
Answer: C
QUESTION 6:
Given the following code:
Actualtests.com - The Power of Knowing
000-703
BEGIN ATOMIC
UPDATE country SET cities=:count WHERE CURRENT OF C1;
INSERT INTO country VALUES(:co11,:co12,:co13);
INSERT INTO country VALUES(:co14,:co15,:co16);
INSERT INTO country VALUES(:co17,:co18,:co19);
INSERT INTO country VALUES(:co110,:co111,:co112);
COMMIT;
END
Given that all statements succeed except the following:
INSERT INTO country VALUES(:co17,:co18,:co19);
How many rows will be affected in table COUNTRY?
A. 0
B. 3
C. 4
D. 5
Answer: A
QUESTION 7:
The following commands are issued against a data source containing table
user2.org:
CREATE ALIAS user1.org FOR sample.org
CREATE TABLE org.sample ( c CHAR(1))
CREATE ALIAS sample.org FOR user2.org
CREATE ALIAS user2.sample FOR sample.org
Given the user SAMPLE issues the following statement:
SELECT * FROM sample
For which of the following database objects will access be attempted?
A. user2.org
B. org.sample
C. sample.org
D. sample.sample
Answer: D
QUESTION 8:
The following commands are issued against a data source:
CREATE TABLE userid.org ( i INT)
CREATE ALIAS user1.org FOR userid.org
CREATE TABLE org.sample ( c CHAR(1))
CREATE ALIAS sample.org FOR userid.org
CREATE ALIAS userid.sample FOR sample.org
Actualtests.com - The Power of Knowing
000-703
When issued by USER1, which of the following statements will have a different
result set than this SELECT statement?
SELECT * FROM org
A. SELECT * FROM org.sample
B. SELECT * FROM sample.org
C. SELECT * FROM userid.org
D. SELECT * FROM userid.sample
Answer: A
QUESTION 9:
An application uses embedded dynamic SQL to connect to a remote DB2 server and
inserts data into the CUST.ORDERS table on that remote DB2 server. To enable
access of the remote DB2 server, Administrator FOO needs to create a package with
default options such that BAR is the only non-administrative user that can use this
package on the remote DB2 server.
Which statement describes the privileges that must be granted and/or revoked by
FOO to accomplish this?
A. BAR requires EXECUTE privilege on the package and UPDATE privilege on
CUST.ORDERS, and the EXECUTE privilege for the package must be revoked from
PUBLIC.
B. BAR requires EXECUTE privilege on the package and INSERT privilege on
CUST.ORDERS, and the EXECUTE privilege for the package must be revoked from
PUBLIC.
C. BAR requires EXECUTE privilege on the package and INSERT privilege on
CUST.ORDERS, and the REFERENCES privilege for the package must be revoked from
PUBLIC.
D. BAR requires EXECUTE privilege on the package and UPDATE privilege on
CUST.ORDERS, and the REFERENCES privilege for the package must be revoked from
PUBLIC.
Answer: B
QUESTION 10:
User FOO must create and own an SQL stored procedure, CUST.CALC1, that
returns a calculation using static SQL. Both user FOO and user BAR need to call
this stored procedure from each of their applications.
Assuming FOO has the necessary privileges to perform the calculation, which two of
the following statements describe the MINIMUM privileges that must be explicitly
granted for users BAR and FOO?
A. BAR needs EXECUTE privilege on the CALC1 package
Actualtests.com - The Power of Knowing
000-703
B. BAR needs EXECUTE privilege on the CALC1 procedure
C. FOO needs EXECUTE privilege on the CALC1 procedure
D. FOO and BAR need EXECUTE privilege on the CALL statement
E. FOO needs the privilege to create the procedure in the CUST schema
Answer: BE
QUESTION 11:
An application uses static SQL to connect to a remote DB2 server and inserts data
into the CUST.ORDERS table on that remote DB2 server. To enable access to the
remote DB2 server, FOO needs to create a package with default options so that
BAR is the only non-administrative user that can use this package on the remote
DB2 server.
Which statement describes the privileges that FOO requires to accomplish this?
A. FOO requires EXECUTE privilege on the package.
B. FOO requires the privilege to create the package on the remote DB2 server.
C. FOO requires EXECUTE privilege on the package and INSERT privilege on
CUST.ORDERS.
D. FOO requires the privilege to create the package on the remote DB2 server and
INSERT privilege on CUST.ORDERS.
Answer: D
QUESTION 12:
Which of the following privileges is required to successfully execute a Java stored
procedure that uses JDBC to update several different tables?
A. The user must have UPDATE privilege on the referenced tables.
B. The developer must have EXECUTE privilege on the stored procedure.
C. The user must have UPDATE privilege on the referenced tables and EXECUTE
privilege on the stored procedure.
D. The developer must have UPDATE privilege on the referenced tables and EXECUTE
privilege on the stored procedure.
Answer: C
QUESTION 13:
Given the table T1, created using the following statement:
CREATE TABLE t1
(
id INTEGER GENERATED BY DEFAULT AS IDENTITY,
c1 CHAR(3)
Actualtests.com - The Power of Knowing
000-703
)
The following SQL statements are issued:
INSERT INTO t1 VALUES (2, 'def')
INSERT INTO t1 VALUES (DEFAULT, 'abc')
INSERT INTO t1 VALUES (DEFAULT, 'ghi')
Which of the following represents the order in which the values are returned from
the following SELECT statement?
SELECT id FROM t1 ORDER BY id
A. 1, 2, 2
B. 1, 2, 3
C. 2, 3, 4
D. 0, 1, 2
Answer: A
QUESTION 14:
Given the following table (C1 is INTEGER):
T1
C1
--
4321
and the stored procedure definition:
CREATE PROCEDURE proc(OUT o1 INT)
READS SQL DATA LANGUAGE SQL
BEGIN
DECLARE v1,v2,v3 INTEGER;
DECLARE cur1 CURSOR FOR
SELECT c1 FROM t1 ORDER BY c1;
DECLARE EXIT HANDLER FOR NOT FOUND
SET o1=v1
OPEN cur1;
FETCH cur1 INTO v2;
FETCH cur1 INTO v3;
SET v1=v2*2+v3;
fetch_loop:
LOOP
SET v2=v3;
FETCH cur1 INTO v3;
SET v1=v1+v2*2+v3;
END LOOP fetch_loop;
END
If the CALL proc(:hv) statement is embedded in an application, what is the value of
:hv after it executes?
Actualtests.com - The Power of Knowing
000-703
A. 20
B. 21
C. 24
D. 25
Answer: B
QUESTION 15:
Which two of the following can be used to retrieve the current date from the DB2
Command Line Processor?
A. ? CURRENT DATE
B. VALUES CURRENT DATE
C. CREATE CURRENT DATE
D. SELECT CURRENT TIME FROM SYSIBM.DUAL
E. SELECT CURRENT DATE FROM SYSIBM.SYSDUMMY1
Answer: BE
QUESTION 16:
Which of the following produces a sequentially increasing number, suitable for use
as a primary key?
A. ROWID data type
B. Generated IDENTITY column
C. GENERATE_UNIQUE built-in function
D. CURRENT SEQUENCE special register
Answer: B
QUESTION 17:
Given the tables, the relationships and the statements:
EMPLOYEE DEPT
emp_num emp_name dept dept_id dept_name
1 Adams 1 1 Planning
2 Jones 1 2 Support
3 Smith 2
4 Williams 1
Relationship: employee.dept is a foreign key on dept.dept_id.
stmt="INSERT INTO employee VALUES (5,'jones',3)";
EXEC SQL EXECUTE IMMEDIATE :stmt;
stmt="INSERT INTO employee VALUES (6,'jhonson',2)';
Actualtests.com - The Power of Knowing
000-703
EXEC SQL EXECUTE IMMEDIATE :stmt;
How many rows are successfully inserted?
A. One row is inserted in EMPLOYEE
B. No rows are inserted in EMPLOYEE
C. Two rows are inserted in EMPLOYEE
D. One row is inserted in DEPT and 2 rows are inserted in EMPLOYEE
Answer: A
QUESTION 18:
Given the tables:
EMPLOYEE DEPT
emp_num emp_name dept dept_id dept_name
1 Adams 1 1 Planning
2 Jones 1 2 Support
3 Smith 2
4 Williams 1
and the statement:
ALTER TABLE employee
ADD FOREIGN KEY (dept) REFERENCES dept (dept_id)
ON DELETE CASCADE
How many rows will be deleted when the following statement is executed?
DELETE FROM employee WHERE dept=1
A. 0
B. 1
C. 3
D. 4
Answer: C
QUESTION 19:
Given the tables:
COUNTRY
id name
1 Argentina
3 Cuba
4-
NATION
id name
2 Belgium
4 USA
and the code:
Actualtests.com - The Power of Knowing
000-703
EXEC SQL DECLARE C1 CURSOR FOR
SELECT * FROM country WHERE name IS NOT NULL
UNION
SELECT * FROM nation
EXEC SQL OPEN C1
How many rows are in the result set?
A. 1
B. 2
C. 3
D. 4
E. 5
Answer: D
QUESTION 20:
Given the tables:
COUNTRY STAFF
id name person cities id name
1 Argentina 1 10 1 Aaron
2 Canada 2 20 2 Adams
3 Cuba 2 10 3 Jones
4 Germany 1 0
5 France 3 5
6 Italy 1 5
the report:
id name number_of_countries
---------- ---------- -------------------
1 Aaron 3
and the SQL statement:
SELECT B.id,B.name,COUNT(DISTINCT A.name) AS number_of_countries
FROM country A, staff B
WHERE B.id=A.person
GROUP BY B.id,B.name
HAVING COUNT(DISTINCT A.name)>:count_var
Which of the following values does :count_var require to print out the above
report?
A. 1
B. 2
C. 3
D. 4
Answer: B
Actualtests.com - The Power of Knowing
000-703
QUESTION 21:
Given the tables T1 and T2, each containing an integer column COL1:
T1
COL1
-----------
1-
1-
22
T2
COL1
-----------
1-
2-
22
and the following query that executes successfully:
SELECT COUNT(*) FROM t1 RIGHT OUTER JOIN t2 ON t1.col1=t2.col1
How many rows are returned?
A. 1
B. 6
C. 8
D. 36
Answer: A
QUESTION 22:
Given the tables T1 and T2, each with an INTEGER column:
T1
COL1
-----------
1-
1-
22
T2
COL1
-----------
1-
2-
22
and the following query that executes successfully:
SELECT * FROM T1 LEFT OUTER JOIN T2 ON T1.COL1=T2.COL1
How many rows will the query return?
A. 5
Actualtests.com - The Power of Knowing
000-703
B. 6
C. 10
D. 36
Answer: C
QUESTION 23:
Given the following statements:
EXEC SQL INSERT INTO employee VALUES(:new_emp, :new_name)
EXEC SQL UPDATE company SET num_employees=num_employees+1
WHERE company_id=1
EXEC SQL COMMIT
Which of the following can be added to the database so that the company table will
still be updated without the need for the explicit UPDATE SQL statement?
A. An INSERT trigger on COMPANY
B. An UPDATE trigger on COMPANY
C. An INSERT trigger on EMPLOYEE
D. An UPDATE trigger on EMPLOYEE
Answer: C
QUESTION 24:
Which of the following CLI/ODBC functions should be used to delete rows from a
DB2 table?
A. SQLDelete()
B. SQLExecDirect()
C. SQLBulkDelete()
D. SQLExecuteUpdate()
Answer: B
QUESTION 25:
Which of the following methods must be used for deleting a row using the Statement
interface in JDBC?
A. delete()
B. execute()
C. executeUpdate()
D. executeDelete()
Answer: C
Actualtests.com - The Power of Knowing
000-703
QUESTION 26:
Given the tables T1 and T2 with INTEGER columns:
T1
COL1
-----------
1-
1-
22
T2
COL1
-----------
1-
2-
22
and the following statement that executes successfully:
DELETE FROM t1 WHERE col1 IN (SELECT * FROM t2)
How many rows will be left in T1 after running this statement?
A. 0
B. 2
C. 3
D. 6
Answer: B
QUESTION 27:
An ODBC/CLI application performs an array insert into a table containing a
primary key. If one of the values inserted generates a duplicate row error, which of
the following APIs can be called to determine the failing row?
A. SQLError()
B. SQLNumRows()
C. SQLRowCount()
D. SQLGetDiagField()
Answer: D
QUESTION 28:
Which of the following is a benefit of user-defined functions?
A. Improves application concurrency
B. Improves blocking of result sets
Actualtests.com - The Power of Knowing
000-703
C. Simplifies application maintenance
D. Reduces memory requirements on the server
Answer: C
QUESTION 29:
Given the table called NAME with the following column and data:
lname
------
Smith
SMITH
SmiTh
smith
Which of the following SQL statements will return all four rows in upper case?
A. SELECT CAPS(lname) FROM name
B. SELECT UCASE(lname) FROM name
C. SELECT STRUPR(lname) FROM name
D. SELECT TOUPPER(lname) FROM name
Answer: B
QUESTION 30:
Given the following table:
CREATE TABLE employee
(name CHAR(10), salary DEC NOT NULL WITH DEFAULT)
INSERT INTO employee (name, salary) VALUES ('SMITH', 30000)
INSERT INTO employee (name) VALUES ('JONES')
INSERT INTO employee (name, salary) VALUES ('ALI', 35000)
Which of the following statements will retrieve more than one row?
A. SELECT salary FROM employee WHERE salary IN (SELECT (salary/(SELECT
SUM(salary) FROM employee)) FROM employee)
B. SELECT COALESCE(AVG(salary)) FROM employee
C. SELECT SUM(salary)/COUNT(*) FROM employee
D. SELECT salary/(SELECT SUM(salary) FROM employee) FROM employee
Answer: D
QUESTION 31:
Which of the following will retrieve results that will only be in lower case?
A. SELECT NAME FROM EMPLOYEE WHERE NAME='ali'
Actualtests.com - The Power of Knowing
000-703
B. SELECT NAME FROM EMPLOYEE WHERE LCASE(NAME)='ali'
C. SELECT UCASE(NAME) FROM EMPLOYEE WHERE LCASE(NAME)='ali'
D. SELECT NAME FROM EMPLOYEE WHERE NAME IN (SELECT NAME FROM
EMPLOYEE WHERE LCASE(NAME)=LCASE('ALI'))
Answer: A
QUESTION 32:
Given the expression:
WITH most_cities AS
(
SELECT b.id,b.name,a.cities
FROM country a, staff b
WHERE a.person = b.id AND
cities > :threshold
)
SELECT * FROM most_cities
In which of the following does MOST_CITIES exist?
A. user tables
B. server memory
C. user table space
D. system catalog tables
Answer: B
QUESTION 33:
Given the code:
EXEC SQL WITH most_cities AS
(
SELECT b.id, b.name, a.cities
FROM country a, staff b
WHERE a.person = b.id AND
cities > :threshold
)
SELECT id, name, cities FROM most_cities
INTO :id, :name, :cities
WHERE cities IN (SELECT MAX(cities) FROM most_cities)
Which of the following can reference MOST_CITIES?
A. The current statement
B. Statements from any application
C. All statements within this application
D. All statements within the current unit of work
Actualtests.com - The Power of Knowing
000-703
Answer: A
QUESTION 34:
If a stored procedure returns multiple rows, which of the following must the calling
application use to access the result set?
A. A cursor
B. A select statement
C. A declared temporary table
D. A table user-defined function
Answer: A
QUESTION 35:
How many rows can be retrieved using a single SELECT INTO statement?
A. Only one row
B. As many as are in the result
C. As many as are host variables used in the call
D. As many as host variable array structures can hold
Answer: A
QUESTION 36:
A cursor is declared with the WITH HOLD option. Which of the following
statements is always true?
A. The cursor will remain open after a COMMIT.
B. All rows retrieved are locked until a COMMIT.
C. A COMMIT will not be allowed until the cursor is closed.
D. Locks obtained by the cursor will be kept after a COMMIT.
Answer: A
QUESTION 37:
Which of the following is TRUE for all cursors defined as FOR FETCH ONLY?
A. The cursors are unambiguous.
B. Only the first row is returned.
C. Cursor stays open after a commit.
D. A temporary table is created on the server.
Actualtests.com - The Power of Knowing
000-703
Answer: A
QUESTION 38:
Given the application code:
EXEC SQL DECLARE cur CURSOR WITH HOLD FOR SELECT c1 FROM t1
EXEC SQL OPEN cur
EXEC SQL FETCH cur INTO :hv /* Statement 1 */
EXEC SQL COMMIT /* Statement 2 */
EXEC SQL FETCH cur INTO :hv /* Statement 3 */
EXEC SQL ROLLBACK /* Statement 4 */
EXEC SQL CLOSE cur /* Statement 5 */
If the table T1 has no rows in it, which statement will cause the cursor "cur" to be
closed first?
A. Statement 1
B. Statement 2
C. Statement 3
D. Statement 4
E. Statement 5
Answer: D
QUESTION 39:
Given the table T1 with the following data:
C1
---
ABC
DE
and the application code:
EXEC SQL DECLARE cur1 CURSOR WITH HOLD FOR
SELECT c1 FROM t1 ORDER BY c1
EXEC SQL DECLARE cur2 CURSOR WITH HOLD FOR
SELECT c1 FROM t1 ORDER by c1
EXEC SQL OPEN cur1
EXEC SQL OPEN cur2
EXEC SQL FETCH cur1 INTO :hv
EXEC SQL FETCH cur1 INTO :hv
EXEC SQL FETCH cur2 INTO :hv
EXEC SQL COMMIT
EXEC SQL FETCH cur2 INTO :hv
EXEC SQL FETCH cur2 INTO :hv
EXEC SQL FETCH cur1 INTO :hv
EXEC SQL CLOSE cur2
Actualtests.com - The Power of Knowing
000-703
EXEC SQL CLOSE cur1
What is the final content of the host variable "hv"?
A. A
B. B
C. C
D. D
Answer: C
QUESTION 40:
Given the following table:
TestTable
C1
-----------
12345
And if the following CLI calls are made:
SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&henv);
SQLSetEnvAttr( henv,
SQL_ATTR_ODBC_VERSION,
(SQLPOINTER) SQL_OV_ODBC3,0);
SQL AllocHandle(SQL_HANDLE_DBC,henv,&hdbc);
SQLConnect( hdbc,
(SQLCHAR *)"db", SQL_NTS,
(SQLCHAR *)"userid", SQL_NTS,
(SQLCHAR *)"password", SQL_NTS
);
SQLSetConnectAttr( hdbc,
SQL_ATTR_AUTOCOMMIT,
SQL_AUTOCOMMIT_OFF,
0);
SQLAllocHandle(SQL_HANDLE_STMT,hdbc,&hstmt);
SQLPrepare(hstmt,(unsigned char*)"select *from Test order by C1',SQL_NTS);
SQLBindCol(hstmt,1,SQL_C_SHORT,&data,0,NULL);
SQLExecute(hstmt);
SQLFetch(hstmt);
printf(Data:%i\n",data);
SQLFetch(hstmt);
printf(Data:%i\n",data);
SQLFetch(hstmt);
printf(Data:%i\n",data);
SQLEndTran(SQL_HANDLE_ENV,henv,SQL_COMMIT);
SQLFetch(hstmt);
printf(Data:%i\n",data);
Actualtests.com - The Power of Knowing
000-703
Which of the following will be returned by the program?
A. Data: 1
Data: 2
Data: 3
Data: 3
B. Data: 1
Data: 2
Data: 3
Data: 4
C. Data: 1
Data: 2
Data: 3
Data: 1
D. Data: 1
Data: 2
Data: 3
Data: 5
Answer: B
QUESTION 41:
Given the table COUNTRY with the following data:
ID NAME PERSON CITIES
-- ---- ------ ------
1 Argentina 1 -
and the code:
EXEC SQL DECLARE c1 CURSOR FOR SELECT id,name FROM country;
EXEC SQL OPEN c1;
EXEC SQL FETCH c1 INTO :id,:name;
EXEC SQL FETCH c1 INTO :id,:name;
Which of the following SQLCODE/SQLSTATEs will be contained in the SQLCA
after the last fetch?
A. SQLCODE 0, SQLSTATE 00000
B. SQLCODE 100, SQLSTATE 02000
C. SQLCODE -100, SQLSTATE 00100
D. SQLCODE -501, SQLSTATE 24501
Answer: B
QUESTION 42:
Actualtests.com - The Power of Knowing
000-703
Which of the following cursor definitions will define a cursor called c2 that will
fetch rows from table t2, and for every row fetched will update column c1 in table
t2?
A. DECLARE c2 CURSOR FOR SELECT * FROM t2 FOR UPDATE OF t2
B. DECLARE c2 CURSOR FOR SELECT * FROM t2 FOR UPDATE OF c2
C. DECLARE c2 CURSOR FOR SELECT * FROM t2 FOR UPDATE OF c1
D. DECLARE c2 CURSOR WITH HOLD FOR SELECT * FROM t2 FOR UPDATE
OF t2
Answer: C
QUESTION 43:
Given the table T1 with the following data:
C1 C2
-- --
11
22
An application issues the following SQL statements with AUTOCOMMIT disabled:
UPDATE t1 SET c1 = 10 WHERE c2 = 1
UPDATE t1 SET c1 = 20 WHERE c2 = 2
SAVEPOINT sp1
UPDATE t1 SET c1 = 30 WHERE c2 = 1
UPDATE t1 SET c1 = 40, c2 = 3 WHERE c2 = 2
SAVEPOINT sp1
UPDATE t1 SET c1 = 50 WHERE c2 = 1
UPDATE t1 SET c1 = 60 WHERE c2 = 2
ROLLBACK TO SAVEPOINT sp1
UPDATE t1 SET c1 = 50 WHERE c2 = 3
COMMIT
What is the result of the following query?
SELECT c1, c2 FROM t1 ORDER BY c2
A. 10 1
20 2
B. 30 1
50 3
C. 30 1
40 3
D. 10 1
50 3
Answer: B
Actualtests.com - The Power of Knowing
000-703
QUESTION 44:
Given the table T1 containing an INTEGER column:
C1
---
1
A multithreaded ODBC/CLI application successfully executes the following
pseudocode in sequence:
Thread 1:SQLConnect(hDbc1,"CERTDB",SQL_NTS,"",NULL,"",NULL);
Thread 2:SQLConnect(hDbc2,"CERTDB",SQL_NTS,"",NULL,"",NULL);
Thread 1: SQLSetConnectAttr( hDbc1, SQL_ATTR_AUTOCOMMIT,
SQL_AUTOCOMMIT_ON);
Thread 2: SQLSetConnectAttr( hDbc2, SQL_ATTR_AUTOCOMMIT,
SQL_AUTOCOMMIT_ON);
Thread1:SQLA11ocHandle(SQL_HANDLE_STMT,hDbc1,&hStmt1);
Thread2:SQLA11ocHandle(SQL_HANDLE_STMT,hDbc2,&hStmt2);
Thread 1: SQLExecDirect( hStmt1, "SAVEPOINT sp1 ON ROLLBACK RETAIN
CURSORS",SQL_NTS);
Thread 1:SQLExecDirect(hStmt,"INSERT INTO T1 VALUES(2)",SQL_NTS);
Thread 2: SQLExecDirect( hStmt2, "SAVEPOINT sp1 ON ROLLBACK RETAIN
CURSORS",SQL_NTS);
Thread2:SQLExecDirect(hStmt2,"INSERT INTO T1 VALUES(3)",SQL_NTS);
Thread1:SQLExecDirect(hStmt1,"INSERT INTO T1 VALUES(4)",SQL_NTS);
Thread2:SQLExecDirect(hStmt2,"ROLLARBACK TO SAVEPOINT spl",SQL_NTS);
Thread2:SQLExecDirect(hStmt2,"INSERT INTO T1 VALUES(4)",SQL_NTS);
Which result set would be returned by:
Thread 2: SQLExecDirect( hStmt2, "SELECT c1 FROM t1 ORDER BY C1", SQL_NTS
);
A. 1,5
B. 1,2,5
C. 1,2,4,5
D. 1,2,3,4
Answer: C
QUESTION 45:
Given an ODBC/CLI program with a single connection, two threads and the
following actions which complete successfully:
Thread 1: INSERT INTO mytab VALUES (1)
Thread 2: INSERT INTO mytab VALUES (2)
Thread 1: COMMIT
Thread 2: INSERT INTO mytab VALUES (3)
Thread 1: ROLLBACK
Actualtests.com - The Power of Knowing
000-703
Thread 2: COMMIT
How many records will be inserted and retained in the table MYTAB?
A. 0
B. 1
C. 2
D. 3
Answer: C
QUESTION 46:
Which of the following database resources can be freed when a unit of work is
committed?
A. row locks
B. cursor names
C. buffer pools
D. cursors WITH HOLD
Answer: A
QUESTION 47:
Given the table T1 with the following data:
COL1 IDX
---- ----
A single-threaded CLI application executes the following pseudocode in sequence:
SQLAllocHandle( SQL_HANDLE_ENV, NULL, &hEnv )
SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc )
SQLConnect( hDbc, "SAMPLE", SQL_NTS, NULL, SQL_NTS, NULL, SQL_NTS )
SQLSetConnectAttr( hDbc, SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_ON
)
SQLAllocHandle( SQL_HANDLE_STMT, hDbc, &hStmt )
SQLExecDirect( hStmt, "UPDATE table1 SET col1=10 WHERE idx=1", SQL_NTS )
SQLExecDirect( hStmt, "UPDATE table1 SET col1=20 WHERE idx=2", SQL_NTS )
SQLEndTran( SQL_HANDLE_DBC, hDbc, SQL_COMMIT )
SQLExecDirect( hStmt, "UPDATE table1 SET col1=30 WHERE idx=1", SQL_NTS )
SQLExecDirect( hStmt, "UPDATE table1 SET col1=40 WHERE idx=1", SQL_NTS )
SQLEndTran( SQL_HANDLE_DBC, hDbc, SQL_ROLLBACK )
SQLExecDirect( hStmt, "SELECT col1 FROM table1 WHERE idx=1", SQL_NTS )
Which of the following values for COL1 will be fetched when the sequence for the
pseudocode listed above is successfully executed?
A. 10
B. 20
Actualtests.com - The Power of Knowing
000-703
C. 30
D. 40
Answer: D
QUESTION 48:
Given the table T1 with two INTEGER columns and the following data:
col1 idx
---- ----
A single-threaded CLI application executes the following pseudocode in sequence:
SQLConnect( hDbc, "CERTDB", SQL_NTS, NULL, SQL_NTS, NULL, SQL_NTS )
SQLSetConnectAttr( hDbc, SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_ON
)
SQLAllocHandle( SQL_HANDLE_STMT, hDbc, &hStmt )
SQLExecDirect( hStmt, "UPDATE table1 SET col1=10 WHERE idx=1", SQL_NTS )
SQLExecDirect( hStmt, "UPDATE table1 SET col1=20 WHERE idx=2", SQL_NTS )
SQLEndTran( SQL_HANDLE_DBC, hDbc, SQL_ROLLBACK )
SQLExecDirect( hStmt, "SAVEPOINT sp1 ON ROLLBACK RETAIN CURSORS",
SQL_NTS )
SQLExecDirect( hStmt, "UPDATE table1 SET col1=30 WHERE idx=1", SQL_NTS )
SQLExecDirect( hStmt, "ROLLBACK TO SAVEPOINT sp1", SQL_NTS )
SQLEndTran( SQL_HANDLE_DBC, hDbc, SQL_COMMIT )
SQLExecDirect( hStmt, "SELECT col1 FROM table1 WHERE idx=1", SQL_NTS )
Which of the following values for COL1 will be fetched when the sequence for the
pseudocode listed above is successfully executed?
A. -
B. 10
C. 20
D. 30
Answer: D
QUESTION 49:
Under which of the following situations must dynamic SQL be used?
A. When temporary table references exist at compile time
B. When the host variables' values are unknown at compile time
C. When the columns in the SELECT clause are unknown at compile time
D. When the number of rows being returned are unknown at compile time
Answer: C
Actualtests.com - The Power of Knowing
000-703
QUESTION 50:
Which of the following is used to run an embedded dynamic SQL UPDATE
statement?
A. UPDATE
B. PREPARE
C. DECLARE
D. EXECUTE
Answer: D
QUESTION 51:
Which of the following indicates when ODBC must be used instead of embedded
SQL?
A. When a precompiler is unavailable
B. When a TYPE 2 connection is required
C. When multiple data sources are accessed
D. When DB2 UDB for OS/390 or iSeries is accessed
Answer: A
QUESTION 52:
Which of the following programming interfaces minimizes client-server
communication traffic by chaining PREPARE and EXECUTE requests together by
default?
A. ODBC/CLI
B. SQL Routines
C. Static Embedded SQL
D. Dynamic Embedded SQL
Answer: A
QUESTION 53:
A programmer wants to create an applet that connects to a DB2 UDB database
from the web browser. Which two of the following can be used?
A. CLI
B. SQLJ
C. JDBC
D. ODBC
Actualtests.com - The Power of Knowing
000-703
E. OLEDB
Answer: BC
QUESTION 54:
Which programming language must be used to code SQLJ stored procedures?
A. Java
B. COBOL
C. C/C++
D. SQL/PSM
Answer: A
QUESTION 55:
Which of the following components is required to convert an embedded SQL source
file into a valid host language source file?
A. Binder
B. Precompiler
C. Host language linker
D. Host language compiler
Answer: B
QUESTION 56:
Which two of the following embedded SQL statements contain host variables?
A. CONNECT TO sample USER :userid USING :passwd
B. SELECT tabschema, tabname FROM syscat.tables WHERE tabname=?
C. DECLARE c1 CURSOR FOR SELECT dept FROM staff WHERE job='MGR'
D. DECLARE c1 CURSOR FOR SELECT * FROM employee WHERE lastname=?
E. SELECT workdept INTO :wd :wdind FROM employee WHERE lastname = 'SMITH'
Answer: AE
QUESTION 57:
Host variables must be defined inside which of the following in order to be used in
an embedded SQL program?
A. DECLARE section
B. SQL INCLUDE file
Actualtests.com - The Power of Knowing
000-703
C. EXEC SQL section
D. Function declaration
Answer: A
QUESTION 58:
A column is defined as INTEGER and contains the following values in no particular
order:
-1, 0, 1, NULL
How many host variables must be included in a DECLARE section in order to select
all the values into the program one row at a time?
A. 1
B. 2
C. 3
D. 4
Answer: B
QUESTION 59:
When declaring an indicator host variable, which of the following data types must
be used?
A. Small integer
B. Fixed character
C. Float (double precision)
D. Variable length character
Answer: A
QUESTION 60:
Which of the following can modify the contents of host variables within a program?
A. Only SQL statements
B. Only using the DECLARE section
C. Program statements and SQL statements
D. Program statements but not SQL statements
Answer: C
QUESTION 61:
Given the declaration in an SQLJ program:
Actualtests.com - The Power of Knowing
000-703
String var1=null;
String var2=null;
Which of the following statements illustrates the correct usage of host variables?
A. #sql {UPDATE mytable SET col1=var1 WHERE col2=?}
B. #sql {SELECT col1 INTO ? FROM mytable WHERE col2=?}
C. #sql {UPDATE mytable SET col1=var1 WHERE col2=var2}
D. #sql {SELECT col1 INTO :var1 FROM mytable WHERE col2=:var2}
Answer: D
QUESTION 62:
Which of the following SQLCA elements contains platform independent values?
A. sqlcode
B. sqlerrp
C. sqlwarn
D. sqlstate
Answer: D
QUESTION 63:
Which of the following SQLCA elements can contain text strings which are used to
send messages to an application?
A. sqlerrp
B. sqlerrd
C. sqlerrml
D. sqlerrmc
Answer: D
QUESTION 64:
Given the following embedded SQL code:
EXEC SQL SET CONNECTION sample
What is the expected result upon successful execution?
A. The previous connection is closed.
B. The CURRENT SERVER special register is cleared.
C. A new connection to the alias "sample" is established.
D. The existing connection state for alias "sample" is changed from dormant to current.
Answer: D
Actualtests.com - The Power of Knowing
000-703
QUESTION 65:
Which two of the following are correct embedded SQL syntax for connecting to a
database?
A.EXEC SQL CONNECT TO sample;
B.EXEC SQL CONNECT TO:dbalias:uid:passwd;
C.EXEC SQL CONNECT TO sample USER ? USING ?;
D.EXEC SQL CONNECT TO:dbalias:uidUSING:passwd;
E.EXEC SQL CONNECT TYPE 2 TO sample USER:uidUSING:passwd;
Answer: AD
QUESTION 66:
Which two of the following embedded SQL statements can be used to specify which
database server is being operated on when performing multi-site updates?
A. CONNECT TO
B. SET CONTEXT
C. SET CONNECTION
D. UPDATE CONTEXT
E. SET CONNECT TYPE 2
Answer: AC
QUESTION 67:
Which of the following special registers can be queried to determine the database
name of the active connection?
A. CURRENT NODE
B. CURRENT SQLID
C. CURRENT SERVER
D. CURRENT CONNECTION
Answer: C
QUESTION 68:
Which of the following is the correct order to allocate ODBC/CLI handles?
A. 1. Environment
2. Connection
3. Statement
Actualtests.com - The Power of Knowing
000-703
B. 1. Connection
2. Environment
3. Statement
C. 1. Environment
2. Statement
3. Connection
D. 1. Statement
2. Connection
3. Environment
Answer: A
QUESTION 69:
Which two of the following are valid ODBC/CLI handle definitions?
A. SQL_HANDLE_ERR
B. SQL_HANDLE_DRV
C. SQL_HANDLE_DBC
D. SQL_HANDLE_CON
E. SQL_HANDLE_DESC
Answer: CE
QUESTION 70:
Prior to executing a query with a forward-only cursor, which of the following
ODBC statement handle attributes can be used to specify that the results of the
query are to be read-only?
A. SQL_ATTR_CONCURRENCY
B. SQL_ATTR_CURSOR_TYPE
C. SQL_ATTR_RETRIEVE_DATA
D. SQL_ATTR_CURSOR_SENSITIVITY
Answer: A
QUESTION 71:
Which two of the following ODBC/CLI API function calls can be used to retrieve
diagnostic information?
A. SQLGetMsg
B. SQLGetError
C. SQLGetDiagRec
D. SQLGetErrorRec
Actualtests.com - The Power of Knowing
000-703
E. SQLGetDiagField
Answer: CE
QUESTION 72:
Given the following ODBC/CLI Code:
SQLHANDLE henv.hdbc,hstmt1,hstmt2;
SQLRETURN rv;
hstmt1=NULL;
hstmt2=NULL;
rc=SQLA11ocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&henv);
rc=SQLA11ocHandle(SQL_HANDLE_DBC,henv,&hdbc);
rc = SQLConnect( hdbc, "SAMPLE", SQL_NTS, "DB2CERT", SQL_NTS,
DB2CERT",SQL_NTS);
rc=SQLA11ocHandle(SQL_HANDLE_STMT,hdbc,&hstmt1);
Assuming all of the above calls return SQL_SUCCESS, which is the expected value
of variable rc if the following function call is made immediately after the above?
rc=SQLExecDirect(hstmt2,"SELECT*FROM SYSIBM.SYSTABLES",SQL_NTS);
A. SQL_ERROR
B. SQL_SUCCESS
C. SQL_INVALID_HANDLE
D. SQL_SUCCESS_WITH_INFO
Answer: C
QUESTION 73:
Under which of the following conditions has an application conclusively retrieved all
diagnostic records associated with a given handle?
A. SQLError() returns SQL_NO_DATA_FOUND
B. SQLGetDiagField() returns SQL_SUCCESS
C. SQLGetDiagRec() returns SQL_NO_DATA_FOUND
D. SQLGetDiagRec() does not return SQL_ERROR
Answer: A
QUESTION 74:
Which of the following ODBC/CLI APIs can be used to retrieve multiple error
messages associated with a single handle in any order?
A. SQLError()
B. SQLGetSQLCA()
Actualtests.com - The Power of Knowing
000-703
C. SQLGetErrorMsg()
D. SQLGetDiagField()
Answer: D
QUESTION 75:
Given the following table T1 containing an INTEGER column:
C1
---
NULL
123
An ODBC/CLI application executes the following pseudocode on an allocated
statement handle:
SQLprepare(hStmt,"SELECT*FROM t1 WHERE c1 IS NULL",SQL_NTS);
SQLBindParameter(hStmt,1,1,SQL_C_LONG,SQL_CHAR,&piData,0,NULL);
SQLExecute(hStmt);
SQLSetStmtAttr(hStmt,SQL_ATTR_CURSOR_TYPE,SQL_CURSOR_STATIC);
SQLFetch(hStmt);
Which API is expected to return SQL_ERROR?
A. SQLFetch()
B. SQLPrepare()
C. SQLExecute()
D. SQLSetStmtAttr()
E. SQLBindParameter()
Answer: D
QUESTION 76:
Given the following table definition:
CREATE TABLE t1 ( c1 CHAR(100) NOT NULL )
An ODBC/CLI application successfully executes the following pseudocode:
SQLA11ocHandle(SQL_HANDLE_SMT,hDbc,&hStmt);
SQLPrepare(hStmt,"INSERT INTO t1 (c1) VALUES(?)",SQL_NTS);
SQLBindParameter( hStmt, 1, 1, SQL_C_CHAR, SQL_VARCHAR, 101, 0, &pszData,
10,pcbValue);
What value of pcbValue would cause the following to return SQL_NEED_DATA?
SQLExecute(hStmt);
A. 0
B. SQL_NTS
C. SQL_NULL_DATA
D. SQL_DATA_AT_EXEC
Actualtests.com - The Power of Knowing
000-703
Answer: D
QUESTION 77:
Given the following ODBC/CLI code that executes successfully:
SQLRETURN rc;
SQLHANDLE hEnv,hDbc,hStmt;
rc=SQLA11ocHandle(SQL_HANDLE_ENV,NULL,&hEnv);
rc=SQLA11ocHandle(SQL_HANDLE_DBC,henv,&hDbc);
rc=SQLConnect(hDbc,"CERTDB",SQL_NTS,NULL,NULL,NULL,NULL);
Which of the following calls is expected to return SQL_SUCCESS?
A.rc=SQLExecute(hStmt);
B.rc=SQLA11ocHandle(SQL_HANDLE_STMT,hDbc,&hStmt);
C.rc=SQLPrepare(hStmt,"SELRCT*FROM SYSIBM.SYSTABLES",SQL_NTS);
D. rc = SQLSetStmtAttr( hStmt, SQL_ATTR_CURSOR_TYPE,
SQL_CURSOR_STATIC,NULL);
Answer: B
QUESTION 78:
Given the following ODBC/CLI pseudocode executes without error:
SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc )
SQLConnect( hDbc, "DB2CERT", SQL_NTS, NULL, SQL_NTS, NULL, SQL_NTS )
SQLSetConnectAttr( hDbc, SQL_ATTR_AUTOCOMMIT,
SQL_AUTOCOMMIT_OFF, NULL )
SQLAllocHandle( SQL_HANDLE_STMT, hDbc, &hStmt )
SQLPrepare( hStmt, "SELECT col1, col2 FROM tab1", SQL_NTS )
SQLExecute( hStmt )
SQLFetch( hStmt )
Which two of the following psuedocode pieces may be successfully executed
immediately after the above?
A. SQLFetch( hStmt )
B. SQLDisconnect( hDbc )
C. SQLBindCol( hStmt, 1, SQL_C_LONG, &buff, 4, NULL )
D. SQLExecDirect( hStmt, "SELECT col1, col2 FROM tab2", SQL_NTS )
E. SQLSetStmtAttr( hStmt, SQL_ATTR_CURSOR_TYPE, SQL_CURSOR_STATIC,
NULL )
Answer: AC
QUESTION 79:
Which two of the following ODBC/CLI APIs can result in the opening of a cursor?
Actualtests.com - The Power of Knowing
000-703
A. SQLFetch()
B. SQLPrepare()
C. SQLGetData()
D. SQLProcedures()
E. SQLExecDirect()
Answer: DE
QUESTION 80:
Which of the following pseudocode ODBC/CLI API calls can be made to determine
if an open cursor is scrollable?
A. SQLFetchScroll( SQL_FETCH_MODE )
B. SQLGetInfo( SQL_SCROLL_OPTIONS )
C. SQLGetStmtAttr( SQL_ATTR_CURSOR_TYPE )
D. SQLGetConnectAttr( SQL_ATTR_CONCURRENCY )
Answer: C
QUESTION 81:
Which of the following CLI/ODBC APIs can be used to establish a new connection
to a remote database?
A. SQLOpenConnect
B. SQLAllocConnect
C. SQLSetConnection
D. SQLDriverConnect
Answer: D
QUESTION 82:
The ODBC/CLI SQLDriverConnect() API is being called through an ODBC Driver
Manager.
To successfully establish a database connection, which of the following attributes is
a required part of the InConnectionString parameter?
A. DSN
B. DBNAME
C. DATASOURCE
D. DB2INSTANCE
Answer: A
Actualtests.com - The Power of Knowing
000-703
QUESTION 83:
Which of the following JDBC objects is used to execute a stored procedure?
A. ResultSet
B. Connection
C. StoredProcedure
D. DatabaseMetaData
E. CallableStatement
Answer: E
QUESTION 84:
Which of the following JDBC objects has methods to retrieve the number of
columns returned from the query?
SELECT * FROM employee
A. RowSet
B. ResultSet
C. RowSetMetaData
D. ResultSetMetaData
Answer: D
QUESTION 85:
Which two of the following JDBC objects can be used to execute SQL that contains
parameter markers?
A. Statement
B. ResultSet
C. CallableStatement
D. PreparedStatement
E. ResultSetMetaData
Answer: CD
QUESTION 86:
Which two of the following JDBC objects can be used to execute the following
query?
SELECT * FROM EMPLOYEE
A. Statement
Actualtests.com - The Power of Knowing
000-703
B. ResultSet
C. Connection
D. PreparedStatement
E. ResultSetMetaData
Answer: AD
QUESTION 87:
Given the INTEGER table T1:
C1
--
12
A JDBC application successfully executes the following:
int cabBeNull;
Statement stmt=con.createStatement();
ResultSet rs = stmt.Execute(SELECT c1 FROM t1");rs.next();
Which of the following demonstrates updating canBeNull to reflect whether column
C1 can contain NULL data for any row?
A.int Val= rs.getInt("C1");
canBeNull=rs.wasNull();
B.ResultSetMetaData rsmd=rs.getMetaData();
canBeNull=rsmd.isNullable(1);
C.ColumnMetaData cmd=rs.getCo1MetaData("C1");
canBeNull=cmd.isNullable();
D.ResultSetMetaData rsmd=rs.getMetaData();
canBeNull=rsmd.getColumnNullable("C1");
Answer: B
QUESTION 88:
Which of the following Java-based open standards can be used to issue static queries
with DB2?
A. JRE
B. JDK
C. SQLJ
D. JDBC
Answer: C
QUESTION 89:
Which of the following Java-based open standards use iterator objects to scroll
Actualtests.com - The Power of Knowing
000-703
through the results of a query?
A. JTA
B. JRE
C. JDBC
D. SQLJ
Answer: D
QUESTION 90:
A JDBC connection is established as follows:
Connection con=DriverManager.getConnection("jdbc:db2:sample");
If the connection does not throw any exceptions, which of the following code pieces
determine if there are any warnings?
A.SQL Warning warn=con.getWarnings();
if(warn !=null) {/*There were warnings*/};
B.SQL warning warn=con.getExceptions();
if(warn !=null) {/*There were warnings*/};
C.SQLExceptions warn=DriverManager.getWarnings();
if(warn !=null) {/*There were warnings*/};
D.SQLExceptions warn=con.getExceptions();
if(warn !=null) {/*There were warnings*/}
Answer: A
QUESTION 91:
Which of the following methods of the SQLException class can be queried to
retrieve DB2 specific error values?
A. getSQLCA()
B. getSQLState()
C. getErrorCode()
D. getErrorState()
Answer: C
QUESTION 92:
Which of the following commands is used to customize an SQLJ profile?
A. sqlj
B. db2 prep
C. db2 bind
D. db2profc
Actualtests.com - The Power of Knowing
000-703
Answer: D
QUESTION 93:
When building an SQLJ application, which of the following steps is required to
generate the SQL package?
A. prep
B. javac
C. db2profp
D. db2profc
Answer: D
QUESTION 94:
Given the following Java code fragment:
public void completeTransaction(Xid txToComplete, boolean commit)
throws Exception {
if (commit) {
resource.prepare(txToComplete);
resource.commit(txToComplete,false);
}
else {
resource.rollback(txToComplete);
}}
Which of the following data source classes are required for the successful execution
of the complete Transaction method?
A. DB2DataSource
B. DB2XADataSource
C. DB2JTADataSource
D. DB2ConnectionPoolDataSource
Answer: B
QUESTION 95:
Given the following Java code fragment:
XADataSource ds;
XAConnection conn;
XAResource resource;
...
Actualtests.com - The Power of Knowing
000-703
InitialContext ctx=new InitialContext();
ds=(XADataSource)ctx.lookup('jdbc/db2cert")
conn=ds.getXAConnection();
resource=conn.getXAResource();
What is the maximum number of global transactions that can be associated with the
conn object at any given time?
A. 0
B. 1
C. no limit
D. as defined by the MAX_TRANS attribute of the conn object
Answer: B
QUESTION 96:
Which of the following javax.sql.DataSource properties must be set to establish a
DB2 JDBC connection to a remote database?
A. portNumber
B. serverName
C. networkProtocol
D. userid and password
Answer: B
QUESTION 97:
Which of the following is a valid sequence for the URL string for connecting to data
source using a DB2 JDBC driver?
A. jdbc:db2:<data_source>
B. jdbc:<data_source>:db2
C. db2:<data_source>:jdbc
D. db2:jdbc:<data_source>
Answer: A
QUESTION 98:
An embedded SQL application performs a static SELECT statement of column C1
from table T1. Which of the following code fragments correctly demonstrates
retrieval of the first row of the result set into host variable "hv"?
A. EXEC SQL SELECT c1 FROM t1 USING cur
EXEC SQL FETCH cur INTO :hv
Actualtests.com - The Power of Knowing
000-703
EXEC SQL CLOSE cur
B. EXEC SQL OPEN cur FOR SELECT c1 FROM t1
EXEC SQL FETCH cur INTO :hv
EXEC SQL CLOSE cur
C. EXEC SQL DECLARE cur CURSOR FOR SELECT c1 FROM t1
EXEC SQL OPEN cur
EXEC SQL FETCH cur INTO :hv
EXEC SQL CLOSE cur
D. EXEC SQL PREPARE stmt FOR SELECT c1 FROM t1
EXEC SQL DECLARE cur CURSOR FOR stmt
EXEC SQL OPEN cur
EXEC SQL FETCH cur INTO :hv
EXEC SQL CLOSE cur
Answer: C
QUESTION 99:
Given the following information:
CREATE TABLE t1(c1 VARCHAR(30) NOT NULL, c2 SMALLINT)
and host variables containing the following data:
hv1 = "User1"
hv2 = 24
hv3 = -1
hv4 = 0
Which of the following pseudocode statements will successfully insert a row where
C1 is 'User1' and C2 is 24?
A.text_stmt="INSERT INTO t1 VALUES(?,?)";
EXEC SQL PREPARE stmt FROM :text_stmt;
EXEC SQL EXECUTE stmt USING :hv1, :hv2 :hv3;
B.text_stmt="INSERT INTO t1 VALUES(?,?)";
EXEC SQL PREPARE stmt FROM :text_stmt
EXEC SQL EXECUTE stmt USING :hv1, :hv2 :hv4;
C.text_stmt="INSERT INTO t1 VALUES (?,??)";
EXEC SQL PREPARE stmt FROM :text_stmt;
EXEC SQL EXECUTE stmt USING :hv1, :hv2 :hv3;
D.text_stmt="INSERT INTO t1 VALUES(?,??)";
EXEC SQL PREPARE stmt FROM :text_stmt;
EXEC SQL EXECUTE stmt USING :hv1, :hv2 :hv4;
Answer: B
QUESTION 100:
Which of the following code fragments is considered Dynamic SQL?
Actualtests.com - The Power of Knowing
000-703
A. EXEC SQL EXECUTE IMMEDIATE :hv1
B. EXEC SQL INSERT INTO t1 VALUES :hv1
C. EXEC SQL SELECT c1 FROM t1 INTO :hv1
D. EXEC SQL DECLARE CURSOR cur1 FOR SELECT c1 FROM t1
Answer: A
QUESTION 101:
Which of the following pseudocode fragments correctly performs a dynamic
SELECT statement from TEST_TABLE when the columns are not known?
A. text_stmt = "DECLARE cur CURSOR FOR SELECT * FROM my.test_table"
EXEC SQL PREPARE stmt FROM :text_stmt
EXEC SQL OPEN cur
EXEC SQL FETCH cur USING DESCRIPTOR :my_sqlda
EXEC SQL CLOSE cur
B. text_stmt = "SELECT * FROM my.test_table"
EXEC SQL PREPARE stmt FROM :text_stmt
EXEC SQL DECLARE cur CURSOR FOR stmt
EXEC SQL OPEN cur
EXEC SQL FETCH cur USING DESCRIPTOR :my_sqlda
EXEC SQL CLOSE cur
C. text_stmt = "DECLARE cur CURSOR FOR SELECT * FROM my.test_table"
EXEC SQL PREPARE stmt FROM :text_stmt
EXEC SQL DESCRIBE stmt INTO :my_sqlda
EXEC SQL OPEN cur
EXEC SQL FETCH cur USING DESCRIPTOR :my_sqlda
EXEC SQL CLOSE cur
D. text_stmt = "SELECT * FROM my.test_table"
EXEC SQL PREPARE stmt FROM :text_stmt
EXEC SQL DESCRIBE stmt INTO :my_sqlda
EXEC SQL DECLARE cur CURSOR FOR stmt
EXEC SQL OPEN cur
EXEC SQL FETCH cur USING DESCRIPTOR :my_sqlda
EXEC SQL CLOSE cur
Answer: D
QUESTION 102:
Which of the following applies for Compound Not Atomic SQL?
A. Can contain host language statements.
B. Is not supported against DRDA servers.
C. Statements can succeed or fail regardless of the success or failure of preceding SQL
Actualtests.com - The Power of Knowing
000-703
statements in the same block of Compound SQL.
D. Is the DB2 term for complex SQL statements that include subselects, CASE
statements, declared temporary tables, common table expressions and recursive SQL.
Answer: C
QUESTION 103:
Given the table declaration:
CREATE TABLE x.org (deptnumb SMALLINT, deptname VARCHAR(14), manager
SMALLINT )
DEPTNUMB DEPTNAME MANAGER
-------- -------------- -------
15 New England 50
20 Mid Atlantic 10
38 South Atlantic 30
Users a and b are using CLP with CURSOR STABILITY isolation level and
AUTOCOMMIT turned OFF. They execute the following in sequence:
1. User a:
db2 "DECLARE c1 CURSOR FOR SELECT manager FROM x.org ORDER BY
manager"
db2 "OPEN c1"
2. User b:
db2 "UPDATE x.org SET manager=60 WHERE manager=10"
3. User a:
db2 "FETCH c1"
What will each user see in their windows?
A.User a 10; User b:session hangs;
B.User a:60; User b: complete successfully;
C.User a:30; User b: complete successfully;
D.User a:10; User b: complete successfully;
Answer: D
QUESTION 104:
Which of the following can be locked explicitly?
A. Indexes
B. Catalog tables
C. Base user tables
D. Declared temporary tables
Answer: C
Actualtests.com - The Power of Knowing
000-703
QUESTION 105:
Using Read Stability isolation level, Application A updates row X and does NOT
issue a COMMIT.
Using Uncommitted Read isolation level, Application B attempts to read row X.
What is the result of Application B's attempt to read row X?
A. Application B will receive a lock timeout error.
B. Application B will wait until Application A completes its unit of work.
C. Application B will receive the version of row X that exists after Application A's
update.
D. Application B will receive the version of row X that existed prior to Application A's
update.
Answer: C
QUESTION 106:
Application A updates row R in table T using a cursor with an isolation level of
Read Stability. Application B intends to read row R from table T after application A
updates the row and application A still has an outstanding unit of work.
Which of the following isolation levels would application B require to successfully
complete this task?
A. Read Stability
B. Repeatable Read
C. Uncommitted Read
D. Cursor Stability
Answer: C
QUESTION 107:
Using Uncommitted Read isolation level, Application A updates row X and does
NOT issue a COMMIT.
Using Read Stability isolation level, Application B attempts to read row X.
What is the result of Application B's attempt to read row X?
A. Application B will receive a deadlock error.
B. Application B will wait until Application A completes its unit of work.
C. Application B will receive the version of row X that exists after Application A's
update.
D. Application B will receive the version of row X that existed prior to Application A's
update.
Answer: B
Actualtests.com - The Power of Knowing
000-703
QUESTION 108:
Which of the following connection handle attributes affects concurrency by
changing the isolation level of ODBC/CLI applications?
A. SQL_ATTR_CONNECTTYPE
B. SQL_ATTR_CONCURRENCY
C. SQL_ATTR_CURSOR_TYPE
D. SQL_ATTR_TXN_ISOLATION
Answer: D
QUESTION 109:
The following statements were successfully executed in sequence in a distributed
unit of work with AUTOCOMMIT set to off:
CONNECT TO con1
CONNECT TO con2
INSERT INTO t1 VALUES(1)
SET CONNECTION con1
INSERT INTO t1 VALUES(2)
ROLLBACK
SET CONNECTION con2
RELEASE con1
COMMIT
Which of the following describes the client state?
A. No records were inserted. Connection CON1 is closed.
B. No records were inserted. Both connections are closed.
C. Connection CON2 inserted a record. Both connections are open.
D. Connection CON2 inserted a record. Connection CON1 is closed.
Answer: A
QUESTION 110:
Which of the following is TRUE for a remote unit of work (RUOW)?
A. A Type 2 connection must be used to establish the connection.
B. A unit of work contains operations against a single data source.
C. A unit of work contains operations against multiple data sources.
D. A syncpoint manager must be used to coordinate COMMITs and ROLLBACKs.
Answer: B
Actualtests.com - The Power of Knowing
000-703
QUESTION 111:
Which of the following SQL statements correctly demonstrates parameter marker
usage?
A. SELECT c1 FROM t1 WHERE c2 = ?
B. SELECT ? FROM t1 WHERE c2 = c3
C. SELECT c1 FROM t1 WHERE c2 = :?
D. SELECT c1 FROM t1 WHERE c2 = '?'
Answer: A
QUESTION 112:
Which of the following SQL statements, if issued dynamically, correctly uses
parameter markers?
A. SELECT c1, ? FROM t1
B. SELECT c1, INTEGER(?) FROM t1
C. SELECT c1, ? AS INTEGER FROM t1
D. SELECT c1, CAST(? AS INTEGER) FROM t1
Answer: D
QUESTION 113:
Which of the following JDBC interfaces has methods that permit the use of
parameter markers?
A. ResultSet
B. Statement
C. Connection
D. CallableStatement
Answer: D
QUESTION 114:
Which of the following ODBC/CLI APIs can be used to retrieve the expected SQL
type associated with a parameter marker after a successful SQLPrepare() call?
A. SQLGetInfo()
B. SQLGetParam()
C. SQLGetDescRec()
D. SQLBindParameter()
Actualtests.com - The Power of Knowing
000-703
Answer: C
QUESTION 115:
An ODBC/CLI application executes the following batch SQL:
SQLExecDirect(hStmt,"SELECT c1 FROM t1;SELECT c2 FROM t2;"SQL_NTS);
Which API is used to discard the first result set and make the second available for
processing?
A. SQLFetch()
B. SQLRowCount()
C. SQLMoreResults()
D. SQLCloseCursor()
Answer: C
QUESTION 116:
Which of the following ODBC/CLI statement handle attributes can be set to permit
retrieval of multiple rows with a single SQLFetch() call?
A. SQL_ATTR_MAX_ROWS
B. SQL_ATTR_ROWSET_SIZE
C. SQL_ATTR_PARAMSET_SIZE
D. SQL_ATTR_ROW_ARRAY_SIZE
Answer: D
QUESTION 117:
Which two of the following parameter styles are valid for registering a Java UDF?
A. SQL
B. JAVA
C. DB2SQL
D. GENERAL
E. DB2GENERAL
F. GENERAL WITH NULLS
Answer: BE
QUESTION 118:
Given the following type definition:
CREATE DISTINCT TYPE money AS DECIMAL(11,2)WITH COMPARISONS;
Actualtests.com - The Power of Knowing
000-703
Which of the following is the best choice for the implementation of the subtraction
operation for two values of money data type?
A. Stored Procedure
B. Check Constraint
C. Table User Defined Function
D. Sourced User Defined Function
Answer: D
QUESTION 119:
Which two of the following features are the specific benefits of stored procedures in
the client server environment?
A. Ability to return user defined messages
B. Ability to commit changes on the server
C. Ability to use SQL/PSM for implementation
D. Ability to reduce data flow over the network
E. Ability to separate and reuse business logic
F. Ability to return result sets over the network
Answer: DE
QUESTION 120:
All of the following are benefits of stored procedures in a client server environment,
EXCEPT:
A. Application code reuse
B. Reduced network traffic
C. Decreased server workload
D. Improved application security
Answer: C
QUESTION 121:
An application needs to retrieve a large number of rows from a database across the
network and compute a single value from the retrieved data.
Which of the following methods will reduce the network traffic between the client
and server?
A. Use a trigger
B. Use a stored procedure
C. Combine all rows into a LOB
Actualtests.com - The Power of Knowing
000-703
D. Combine all rows into a User-Defined Type
Answer: B
QUESTION 122:
DB2 stored procedures can be used for all of the following tasks EXCEPT:
A. Opening a cursor declared FOR UPDATE.
B. Issuing a COMMIT to end the unit of work.
C. Preparing and executing dynamic SQL statements.
D. Returning output parameters to an UPDATE statement.
Answer: D
QUESTION 123:
Given the following SQL Stored Procedure:
CREATE PROCEDURE Proc2 ( )
LANGUAGE SQL
P1: BEGIN
DECLARE CONTINUE HANDLER FOR SQLSTATE '38S01'
ErrHandler: BEGIN
INSERT INTO result VALUES(Handler Fired');
RESIGNAL SQLSTATE '38S01'SET MESSAGE_TEXT='Error occured in SP.';
INSERT INTO result VALUES ('After Resignal');
END ErrHandler;
INSERT INTO result VALUES('start');
SIGNAL SQLSTATE '38S01');
INSERT INTO result VALUES('END');
END P1
If the procedure is executed with AUTOCOMMIT set to OFF, which of the
following messages will be inserted into the result table?
A. 'Start'
'Handler Fired'
B. 'Start'
'Handler Fired'
'End'
C. 'Start'
'Handler Fired'
'After Resignal'
D. 'Start'
'Handler Fired'
'After Resignal'
Actualtests.com - The Power of Knowing
000-703
'End'
Answer: A
QUESTION 124:
Given the following procedure:
CREATE PROCEDURE Proc1 ( )
RESULT SETS 1
LANGUAGE SQL
P1: BEGIN
DECLARE C1 CURSOR WITH RETURN FOR
SELECT*FROM T1;
OPEN C1;
END P1
Which statement most accurately describes the result when the procedure is called?
A. A cursor is returned to the procedure caller for all rows of table T1.
B. All rows of table T1 are returned to the procedure caller in an array structure.
C. A cursor is returned to the procedure caller with an empty result set because the TO
CALLER clause is missing on the DECLARE statement.
D. All rows of table T1 are returned to the procedure caller in an array structure and a
warning is returned by the procedure because the cursor is not closed.
Answer: A
QUESTION 125:
DB2 Development Center can be used to develop which of the following?
A. SQL triggers
B. External UDFs
C. SQL stored procedures
D. External stored procedures
Answer: C
QUESTION 126:
Which statement describes the process of creating an SQL stored procedure
through DB2 Development Center?
A. The procedure is precompiled, compiled, and registered on the database server system.
B. The procedure is precompiled and compiled on the development workstation and then
bound to the database server system.
Actualtests.com - The Power of Knowing
000-703
C. The procedure is precompiled and compiled on the development workstation and then
registered on the database server system.
D. The procedure is precompiled on the development workstation and then compiled and
registered on the database server system.
Answer: A
Actualtests.com - The Power of Knowing

You might also like