Sie sind auf Seite 1von 18

Given the following information: tab1 col1 col2 INT NOT NULL, CHAR(40)

and col1 is defined as a primary key. Application A is using Cursor Stability isolation level and issues: UPDATE tab1 SET col2 = 'ABC' WHERE col1=123 Application A's transaction has not committed. Application B issues: SELECT * FROM tab1 WHERE col1=123 and receives an SQLCODE indicating a lock timeout. What statement should application B issue to successfully retrieve the row? SELECT SELECT SELECT SELECT * * * * FROM FROM FROM FROM tab1 tab1 tab1 tab1 WHERE WHERE WHERE WHERE col1=123 col1=123 col1=123 col1=123 WITH UR WITH CS FORCE LOCKS WITH CS KEEP LOCKS

2) Which of the following is a characteristic of all cursors in embedded SQL? Must Must Must Must be be be be reserved in the database. unique within a source file. unique within a unit of work. unique for all applications against a database.

3) Given the following ODBC/CLI pseudocode that executes successfully: SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc ) SQLSetConnectAttr( hDbc, SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF ) SQLConnect( hDbc, "CERTDB", SQL_NTS, NULL, NULL, NULL, NULL ) SQLAllocHandle( SQL_HANDLE_STMT, hDbc, &hStmt ) SQLExecDirect( hStmt, "DELETE FROM EMPLOYEE WHERE EMPNO = '000990'", SQL_NTS ) After execution of the statements above, which two of the following pseudocode API calls is a return code of SQL_SUCCESS expected? SQLFetch( hStmt ) SQLDisconnect( hDbc ) SQLNumResultCols( hStmt ) SQLGetDiagRec( SQL_HANDLE_STMT, hStmt, 0 ) SQLEndTran( SQL_HANDLE_DBC, hDbc, SQL_ROLLBACK ) 4)

USERA has authority to access all tables in a database. Which DB2 application development interface should be used to restrict USERA from accessing tables with payroll information during application runtime? CLI JDBC Embedded static SQL Embedded dynamic SQL 5) Assume that the following SQL statements have been successfully issued: CONNECT TO db1 USER user1 USING pw1 DECLARE GLOBAL TEMPORARY TABLE temp1 (val INTEGER) ... Which of the following statements will successfully insert a row into the temporary table TEMP1? INSERT INTO db1.temp1 VALUES (100) INSERT INTO user1.temp1 VALUES (100) INSERT INTO session.temp1 VALUES (100) INSERT INTO temporary.temp1 VALUES (100) 6) Given that any referenced database objects exist and all host variables have been declared appropriately. Which two of the following lines of embedded SQL code can be successfully precompiled into the appropriate host-language source? EXEC SQL FETCH c1 INTO :var1 :var2 :var3; #sql iter = { SELECT col1 FROM tab1 WHERE col2=:var1 }; SQL UPDATE tab1 SET col1 = :var1 :var2 WHERE col2 = :var3; #sql exec { SELECT col1, col2 FROM tab1 WHERE col2 = :var1 }; EXEC SQL OPEN c1; if (SQLCODE >= 0) EXEC SQL FETCH c1 INTO :var1 :var2; 7) Given the following information: CREATE TABLE people(name VARCHAR(30) NOT NULL, age SMALLINT) and host variables containing the following data: hv1 = "User1" hv2 = 0 hv3 = -1 Which of the following pseudocode statements will successfully insert a row for 'User1' whose age is unknown (represented by the NULL value)? text_stmt = "INSERT INTO people VALUES (?, ?)"; EXEC SQL PREPARE stmt FROM :text_stmt; EXEC SQL EXECUTE stmt USING :hv1, NULL; text_stmt = "INSERT INTO people VALUES (?, ?)"; EXEC SQL PREPARE stmt FROM :text_stmt;

EXEC SQL EXECUTE stmt USING :hv1, :hv2 :hv3; text_stmt = "INSERT INTO people VALUES (?, ??)"; EXEC SQL PREPARE stmt FROM :text_stmt; EXEC SQL EXECUTE stmt USING :hv1, :hv2 :hv3; text_stmt = "INSERT INTO people VALUES (?, ?, ?)"; EXEC SQL PREPARE stmt FROM :text_stmt; EXEC SQL EXECUTE stmt USING :hv1, :hv2, :hv3; 8) Given the following code from an SQLJ source file: Connection con = DriverManager.getConnection(url); DefaultContext ctx = new DefaultContext(con); DefaultContext.setDefaultContext(ctx); If an UPDATE statement is issued using the ctx context, which of the following SQLJ methods should be used to obtain the number of rows modified by the UPDATE statement? ctx.rowsUpdated() ctx.SQLRowCount() ctx.getUpdateCount() con.getUpdateCount() 9) Which of the following static SQL statements can use a host variable? FETCH ROLLBACK DROP INDEX ALTER TABLE 10) A Java program requires the two phase commit support. Which of the following data source classes should be used by this program? DB2DataSource DB2XADataSource DB2JTADataSource DB2ConnectionPoolDataSource 11) Given the tables: COUNTRY id name ----1 Argentina 2 Canada 3 Cuba 4 Germany 5 France and the code: EXEC SQL DECLARE CURSOR C1 FOR SELECT b.name, cities person -----1 2 2 1 7 cities -----10 20 10 0 5 STAFF id -1 2 name ---Aaron Adams

EXEC EXEC EXEC EXEC

FROM country a, staff b WHERE a.person=b.id ORDER BY 1,2; SQL OPEN C1; SQL FETCH C1 INTO :name1 :n_ni, :city1 :c_ni; SQL FETCH C1 INTO :name1 :n_ni, :city1 :c_ni; SQL FETCH C1 INTO :name1 :n_ni, :city1 :c_ni;

Which of the following is the value of :city1 after the third FETCH? 0 5 10 20 12) Which of the following JDBC interfaces contains methods for transaction management? ResultSet Statement Connection DatabaseMetaData 13) All of the following stored procedure parameter styles are supported by the DB2 Development Center, EXCEPT: SQL JAVA DB2SQL DB2GENERAL 14) Which of the following JDBC objects can be used to determine the SQLSTATE if execution of a query fails? Statement ResultSet SQLException ResultSetMetaData 15) Given the following TWO SQL stored procedures: Procedure 1: CREATE PROCEDURE myStorproc(p1 int, p2 char) language sql specific spintchar BEGIN IF ( P1 = 0 OR P1 = 1 ) THEN UPDATE DUMMY SET COL1 = INT(P2); END IF ; END

Procedure 2: CREATE PROCEDURE myStorproc(p1 int) language sql specific spint BEGIN IF ( P1 = 0 OR P1 = 1 ) THEN UPDATE DUMMY SET COL1 = P1 ; END IF ; END Which of the following statements will remove Procedure 1 from the database? DROP DROP DROP DROP DROP 16) PROCEDURE myStorproc (p1, p2) PROCEDURE myStorproc (int, char) SPECIFIC PROCEDURE spintchar (p1, p2) SPECIFIC PROCEDURE spintchar (int, char) SPECIFIC PROCEDURE myStorproc (int, char)

Under which of the following conditions is a Transaction Manager (TM) coordinated Distributed Unit of Work considered an indoubt transaction for a given Resource Manager (RM)? The RM has not received a PREPARE request from the TM. The RM replied to a PREPARE request from the TM and received a ROLLBACK request. The RM replied to a PREPARE request from the TM but has not received any further requests. The RM has acted on a COMMIT request from the TM but another RM participating in the transaction has not. 17) Which of the following programming interfaces can be used to program static queries from a Java application? CLI JTA JDBC SQLJ OLEDB 18) An embedded SQL application contains two modules which do the following: (Module1) EXEC SQL CONNECT TO certdb1 EXEC SQL SELECT col1, col2 INTO :var1 FROM tab1 (Module2) EXEC SQL CONNECT TO certdb2 EXEC SQL SELECT cola, colb INTO :var2 FROM tab2 The application reacts to user input and can call either module in any order. After successful execution of either module, which of the

following can be used to populate the SQLCA with information about the current data source? EXEC EXEC EXEC EXEC 19) Which of the following code fragments demonstrates the use of embedded dynamic SQL? EXEC EXEC EXEC EXEC SQL SQL SQL SQL DECLARE C1 CURSOR FOR S1 UPDATE C1 SET name = :name SELECT name INTO :name FROM T1 DECLARE C1 CURSOR FOR SELECT name FROM T1 SQL SQL SQL SQL CONNECT; GET SQLCA INTO :sqlca; VALUES( CURRENT SERVER ); VALUES ( CURRENT CONNECTION ) INTO :sqlca;

20) Given the tables: ORG id -1 2 2 name ---Programming Testing Testing person -----1 2 3 STAFF id -1 2 3 name ---Aaron Adams Jones

and the following relationship: STAFF.ID is a foreign key referencing ORG.PERSON with the DELETE SET NULL action and the code: stmt="DELETE FROM staff WHERE name='Adams' "; EXEC SQL EXECUTE IMMEDIATE :stmt; How many rows will be deleted? 0 1 2 3 21) Which of the following can be used to access a DB2 database from a workstation that does not have any DB2 code installed? Trigger Java Applet SQL Routines External Stored Procedure 22)

An application needs to perform a business calculation that requires multiple SQL operations. The application clients are distributed on a slow network. Which of the following should a client application make to meet these requirements with maximum application performance? Trigger calls Type 2 connections Static SQL DDL calls Stored procedure calls 23) Given the following ODBC/CLI pseudo-code: SQLExecDirect( hStmt1, "CREATE TABLE t1( c1 INTEGER )", SQL_NTS ) SQLPrepare( hStmt1, "INSERT INTO t1 VALUES (?)", SQL_NTS ) All appropriate application initialization has been done and the APIs are called with values appropriate to this operation. Which two APIs can be called to permit successful execution of the following statement? SQLExecute( hStmt1 ) SQLBindCol() SQLNumParams() SQLSetDescField() SQLBindParameter() SQLDescribeParam() 24) Which of the following is required to successfully execute a DB2 Call Level Interface (CLI) application? The The The The 25) user must developer user must developer have must have must EXECUTE privilege on the application. have EXECUTE privilege on the application. sufficient privileges on referenced tables. have sufficient privileges on referenced tables.

Execution of the following results in a return code of SQL_ERROR: SQLRETURN rc = SQLExecDirect( hHandle1, "SELECT * FROM STAFF", SQL_NTS ); Which of the following handle types must be queried using SQLGetDiagRec() to retrieve diagnostic information about the error? Statement Connection Descriptor Environment 26)

Which of the following ODBC/CLI statement handle attributes permits an application to change the memory address of all bound parameter markers without making any ODBC/CLI API calls? SQL_ATTR_PARAM_BIND_TYPE SQL_ATTR_PARAM_STATUS_PTR SQL_ATTR_PARAM_OPERATION_PTR SQL_ATTR_PARAM_BIND_OFFSET_PTR 27) During which of the following are SQL statements optimized when using DB2 CLI? cursor open precompile phase application binding statement preparation 28) Which of the following demonstrates a correct usage of parameter markers? CALL outsrv( ?, ? ) SELECT col1, col2 FROM tab1 WHERE tab1.? = 15 SELECT count(*) FROM foo.tab1 WHERE col1 = '?' SELECT firstnme FROM employee WHERE lastnme = :? 29) Given the following code: BEGIN NOT ATOMIC UPDATE country SET cities = :count WHERE CURRENT OF C1; INSERT INTO country VALUES (:col1, :col2, :col3); INSERT INTO country VALUES (:col4, :col5, :col6); INSERT INTO country VALUES (:col7, :col8, :col9); INSERT INTO country VALUES (:col10, :col11, :col12); COMMIT; END Given that all statements succeed except the following: INSERT INTO country VALUES (:col7, :col8, :col9); How many rows will be affected in table COUNTRY? 0 3 4 5 30) Which of the following must be used by an application to retrieve multiple rows? SQLCA CURSOR SELECT INTO statement COMPOUND SQL statement

31) Given the following table: Table A Column1 ------R1 R2 R3 R4 R5 R6 and SQL statement: SELECT * FROM tablea ORDER BY column1 An ODBC application with cursor type set to SQL_CURSOR_STATIC and the rowset size of 3 successfully executes the following APIs in sequence: The following ODBC APIs are issued in the order: 1) SQLFetchScroll() with the SQL_FETCH_LAST option 2) SQLFetchScroll() with the SQL_FETCH_ABSOLUTE option, offset=5 3) SQLFetchScroll() with the SQL_FETCH_PRIOR option Which of the following represents the sequence in which rows are retrieved by the application assuming the contents of each rowset are retrieved in order? R1,R2,R3,R2,R3,R4 R4,R5,R6,R1,R2,R3 R1,R2,R3,R2,R3,R4,R3,R4,R5 R4,R5,R6,R5,R6,R2,R3,R4 32) When specified prior to establishing a database connection, which of the following ODBC/CLI connection handle attributes is used to ensure all subsequent SQL statements are executed using Repeatable Read locking semantics by default? SQL_ATTR_LOCK_MODE SQL_ATTR_CONCURRENCY SQL_ATTR_TXN_ISOLATION SQL_ATTR_CURSOR_SENSITIVITY 33) Which of the following JDBC interfaces contains methods that are called to determine whether or not cursors persist across COMMIT boundaries? ResultSet Statement DatabaseMetaData ResultSetMetaData 34) Given the following tables:

EMPLOYEE emp_num ------2 3 4 1

emp_name -------Jones Smith Williams

dept ---Adams 1 2 1

DEPT dept_id ------1 2

dept_name --------1 Planning Support

and the statement: ALTER TABLE employee ADD FOREIGN KEY (dept) REFERENCES dept(dept_id) ON DELETE CASCADE How many rows will be deleted with the following statement? EXEC SQL DELETE FROM dept WHERE dept_id=1 0 1 2 3 4 35) An SQLJ application needs to connect to a remote data source SAMPLE using a userid and password. Which of the following will establish the connection? #sql con={CONNECT TO SAMPLE :userid :password} getConnection("jdbc:db2:SAMPLE",userid,password) getConnection("jdbc:db2:SAMPLE:userid:password") #sql con={CONNECT TO SAMPLE USER :userid USING :password} 36) The FINANCE application contains static SQL and issues the following statements: SELECT name,id FROM prod.employee UPDATE prod.dept SET dept=dept+1 INSERT INTO prod.dept VALUES(:id,:name) Assuming a user can connect to the database, which of the following privileges must be granted to the user so that the FINANCE application can be run by that user? UPDATE privilege on table DEPT RUN privilege on tables EMPLOYEE and DEPT EXECUTE privilege for the FINANCE application CONTROL privilege on tables EMPLOYEE and DEPT 37) Given the following table: CREATE TABLE employee (name CHAR(10), salary DEC)

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 the lowest computed value? SELECT SELECT SELECT SELECT SUM(SALARY)/COUNT(*) FROM EMPLOYEE MIN(SALARY) FROM EMPLOYEE AVG(SALARY) FROM EMPLOYEE SUM(SALARY) FROM EMPLOYEE

38) Given the successful allocation of a new statement handle in an ODBC/CLI application: SQLAllocHandle( SQL_HANDLE_STMT, hDbc, &hStmt ); Which two ODBC/CLI APIs can be called to permit successful execution of the following: SQLExecDirect( hStmt, "SELECT * FROM SYSIBM.SYSTABLES WHERE TABNAME = ?", SQL_NTS ); SQLPrepare() SQLPutData() SQLBindCol() SQLBindParameter() SQLSetDescrField() 39) Which of the following ODBC/CLI APIs can undo a unit of work to a given savepoint? SQLRollback() SQLTransact() SQLSavePoint() SQLExecDirect() 40) Given the following embedded SQL pseudocode: Start Program EXEC SQL BEGIN DECLARE SECTION USERA CHARACTER (8) USERB CHARACTER (8) PW CHARACTER (8) COLVAL CHARACTER (16) EXEC SQL END DECLARE SECTION EXEC SQL INCLUDE SQLCA EXEC SQL WHENEVER SQLERROR GOTO ERRCHK

(program logic) (:usera contains the string "usera") (:pwa contains a valid password) (:userb now contains the string "userb") (:pwb contains a valid password) EXEC SQL CONNECT TO samplea USER :usera USING :pwa EXEC SQL SELECT col1, col2 FROM tablea (program logic to retrieve results) EXEC SQL COMMIT (more program logic) EXEC EXEC EXEC EXEC SQL SQL SQL SQL CONNECT TO sampleb USER :userb USING :pwb SELECT col1, col2 FROM tablex DELETE FROM tablea WHERE col1= :colval //1st delete COMMIT

(more program logic) EXEC SQL SET CONNECTION samplea EXEC SQL DELETE from tablea where col1= :colval EXEC SQL COMMIT EXEC SQL CONNECT RESET ERRCHK (check error information in SQLCA) (Cleanup) End Program What table will be updated in "samplea" if the second DELETE completes successfully? usera.tablex userb.tablea usera.tablea userb.tablex 41) Which two of the following can be retrieved from an ODBC/CLI diagnostic record using the SQLGetDiagRec() API call? SQL_DIAG_SQLCA SQL_DIAG_NUMBER SQL_DIAG_SQLSTATE SQL_DIAG_RETURNCODE SQL_DIAG_MESSAGE_TEXT 42) An embedded SQL program wishes to retrieve a TIMESTAMP from the database. Which of the following host variable data types is required? Float //2nd delete

Decimal Integer array Character string 43) Given the following table and trigger definition: TABLE: DEPTINFO DeptID DeptTitle ====== ========= 1 SALES 2 MKTG 3 DEVELOPMENT

DeptCount ========= 5 2 17

CREATE TRIGGER notify AFTER UPDATE OF deptid,deptcount ON deptinfo REFERENCING OLD AS o NEW AS n FOR EACH ROW DB2SQL MODE WHEN(o.DeptCount=0 OR n.DeptId<4) BEGIN INSERT INTO notifylog VALUES(CURRENT TIMESTAMP,'Check on Dept Changes'); END How many rows will be inserted into the NOTIFYLOG table as a result of the trigger activations caused by the successful execution of the following set of SQL statements? UPDATE DeptInfo SET DeptCount = DeptCount+1 UPDATE DeptInfo SET DeptTitle = 'MARKETING' WHERE DeptId=2 UPDATE DeptInfo SET DeptCount = 10 WHERE DeptID=1 2 3 4 5 44) Given the following tables: PRICE item ---1 2 3 description ----------camera watch shirt cost ---10 5 20 code ---2 1 1 SALE sale_id ------1 2 salefactor ---------2 3

and the SQL statement: SELECT a.cost, (a.cost * b. salefactor) AS saleprice FROM sale b, price a WHERE a.code=b.sale_id ORDER BY a.cost

Which of the following is the value of SALEPRICE in the second row of the result set returned by the above query? 10 15 20 30 40 45) Given the code: EXEC SQL UPDATE t1 SET column1 = :col WHERE CURRENT OF C1; How should the cursor C1 be defined? As As As As a normal cursor a WITH HOLD cursor a FETCH ONLY cursor an updateable cursor

46) All of the following are types of UDFs EXCEPT: Table Column Scalar Summary 47) Given the SQL statement: WITH management (name,totalpay,department,location) AS ( SELECT a.name, (a.salary * :bonusrate), b.deptname, b.location FROM staff a, org b WHERE a.dept=b.deptnumb AND a.job='Mgr' ) SELECT * FROM management WHERE totalpay > :threshold Which of the following is the above an example of? Derived view Derived table Scalar subselect Common table expression 48) Given a table created using the statement: CREATE TABLE abc.stuff (i INT) A user called XYZ is to be enabled to access data from table ABC.STUFF using an implicit schema.

Assuming the necessary privileges have been granted, which of the following statements issued by user ABC will provide this result? CREATE ALIAS stuff FOR abc.stuff CREATE VIEW abc.stuff FOR xyz.stuff CREATE ALIAS abc.stuff FOR xyz.stuff CREATE VIEW xyz.stuff AS SELECT i FROM abc.stuff 49) Given an ODBC/CLI program with a single connection, two threads and the following actions: Thread Thread Thread Thread Thread Thread 1: 2: 1: 1: 2: 1: INSERT INTO INSERT INTO INSERT INTO ROLLBACK INSERT INTO COMMIT mytab VALUES (1) mytab VALUES (2) mytab VALUES (3) mytab VALUES (4)

Assuming that AUTOCOMMIT is ON, how many records will be successfully inserted into the table MYTAB? 1 2 3 4 50) If a required field is missing from the connection string, which SQLDriverConnect() DriverCompletion option will result in the return code SQL_ERROR? SQL_DRIVER_PROMPT SQL_DRIVER_NOPROMPT SQL_DRIVER_COMPLETE SQL_DRIVER_COMPLETE_REQUIRED 51) Which of the following handle types contains information about the application buffers bound to the columns in a result set? Statement Connection Descriptor Environment 52) Given statements from two embedded SQL program executions that run successfully in different connections: Pgm1 INSERT INTO mytab VALUES (1) COMMIT INSERT INTO mytab VALUES (2) ROLLBACK Pgm2 INSERT INTO mytab VALUES (3) ROLLBACK

INSERT INTO mytab VALUES (4) COMMIT How many records will be successfully inserted and retained in the table MYTAB? 1 2 3 4 53) Which of the following JDBC objects are queried to determine the indexes defined on a given table? ResultSet Statement Connection DatabaseMetaData CallableStatement 54) An existing application's logic for business measurement calculations must be separated into reusable database modules. Which of the following database features is most appropriate for the implementation? DB2 Extenders Check Constraint Stored Procedures User Defined Table Functions 55) Which of the following SQLCA elements contains the number of rows affected by the SQL statement? sqlcabc sqlerrp sqlerrd sqlerrml 56) Application A is using Cursor Stability, updates row X and does NOT issue a COMMIT. Application B reads row X. Which of the following isolation levels must application B be using? Read Stability Repeatable Read Cursor Stability Uncommitted Read 57) Which of the following is a required parameter for running db2profc? userid server name prep options profile name

58) Given the following statements: CREATE TABLE mydate (col1 CHAR(10)) INSERT INTO mydate VALUES ('2002-12-15') CREATE TABLE realdate (cola DATE) Which of the following will result in a negative SQLCODE? SELECT INSERT INSERT INSERT DAY(cola) FROM realdate INTO realdate SELECT DATE(col1) FROM mydate INTO realdate SELECT col1 FROM mydate INTO realdate SELECT DAY(col1) FROM mydate

59) Which of the following CLI/ODBC functions will return the number of rows affected by an INSERT, UPDATE or a DELETE statement? SQLNumRows() SQLRowCount() SQLRowsChanged() SQLUpdateCount() 60) Given a cursor C1 on table T1. For every row fetched from T1, open a cursor C2 on table T2. For every row fetched from T2, update column C1 in table T2 and issue a COMMIT. Which of the following must define cursor C1? DECLARE DECLARE DECLARE DECLARE c1 c1 c1 c1 CURSOR CURSOR CURSOR CURSOR WITH HOLD FOR SELECT * FROM t1 WITH RETURN FOR SELECT * FROM t1 FOR SELECT * FROM t1 FOR UPDATE OF t2 FOR SELECT * FROM t1 FOR UPDATE OF c1

61) In which of the following circumstances is an application prevented from locking a table exclusively? When When When When the table is a catalog table a primary key index is locked the table has foreign key constraints the application is involved in a distributed unit of work

62) Given a table that has columns defined: SMALLINT_COLUMN SMALLINT VARCHAR_COLUMN VARCHAR(20) NOT NULL

Which of the following statements is used to retrieve rows from the table and allows the second column to be checked for NULL values? FETCH * INTO :hv1, :hv2 FETCH CURSOR1 INTO :hv1, :hv2

FETCH * INTO :hv1, :hv2 :hv2ind FETCH CURSOR1 INTO :hv1, :hv2 :hv2ind 63) Given the following: EXEC SQL BEGIN DECLARE SECTION; char var1[20]; short var2; EXEC SQL END DECLARE SECTION; Which two of the following examples correctly demonstrate the use of host variables within an SQL statement? EXEC EXEC EXEC EXEC EXEC SQL SQL SQL SQL SQL CONNECT TO var1 FETCH c1 INTO :var1 :var2 UPDATE name_column INTO :var1 SELECT name_column INTO :var1 FROM T1 SELECT name_column INTO :var1, :var2 FROM T1

Das könnte Ihnen auch gefallen