You are on page 1of 154

QUESTION # QUESTIONS

How many types of Scrollable Cursors are there in


1 PL/SQL

How to control how many cursors are open in an


2 session
What is the default Value for OPEN_CURSORS
3 parameter for a session
4 Select the Wrong Statements from the following:
1) In PL/SQL, a cursor is a name assigned to a
specific private SQL area for a specific SQL
statement.
2) For static Cursors,SQL statement is determined
at run time
3) The cursor attribute %FOUND behaves same for
both implicit Cursors and explicit cursors

4) Explicit cursor declarations can contain a


RETURN clause in place of the SELECT statement.
5) Whenever a SQL statement is directly in the
execution or exception section of a PL/SQL block,
you are working with implicit cursors.
When a user process fails, what background
5 process cleans up after it?

What background process refreshes materialized


views?
6
Name a tablespace automatically created when you
create a database.
7
8 How can you enable a trace for a session
1) DBMS_SESSION.SET_SQL_TRACE;

2) ALTER SESSION SET SQL_TRACE = TRUE;


3) FND_SESSION.SET_SQL_TRACE;
You have created the following database link:

CREATE DATABASE LINK db_link2


CONNECT TO scott IDENTIFIED BY tiger
USING 'sales';

You attempt to update the EMP_SAL table by


issuing the following SQL command:

UPDATE emp_sal@db_link2
SET BALANCE = BALANCE + 100
WHERE emp_id=1001;

You receive the following error message:


ORA-01031: insufficient privileges
ORA-02063: preceding line from DB_LINK2

Which of the following reasons might explain your


inability to update the EMP_SAL table in the remote
database?

9
You cannot grant privileges on remote objects to
other users.
10
Which of the following operations cannot be
performed using database links to a remote
11 database.
A) Grant privileges on remote objects
B) Execute DESCRIBE operations on remote
procedure

C) To perform DML operations on the remote data


D) Execute DESCRIBE operation on a remote
package
An ---------------- is a user-defined composite
datatype representing a data structure and functions
12 and procedures to manipulate the data.

13 What is the Basic PL/SQL Code Structure?


14 Which statement is wrong?

15 Which Statement is Wrong about Functions in plsql?


The Procedue Body must have at least one
executable statement after the BEGIN and before
the END or EXCEPTION keywords Is this statement
16 true or false.

17 Which statement is true regarding anonymous block


Which is the PL/SQL procedure that are associated
with tables and are called whenever certain
18 modifications(events) occurs.
The pl/sql block in the structure of atrigger is a usual
code block where you can place pl/sql commands
19 excepts COMMIT or ROLLBACK

The PERSON table contains 5 records.An update


trigger is created on the table as below
CREATE OR REPLACE TRIGGER
PERSON_TRIGGER BEFORE UPDATE
ON PERSON
BEGIN
DBMS_OUTPUT.PUT_LINE('BEFORE UPDATING
PERSON(S)');
END;
What will be the result of below update statement on
the table?
20 Update PERSON SET DOB = SYSDATE;

21 What is the syntax to drop a trigger?


is a database structure that provides quick lookup of
22 data in a column or columns of a table.
A ---- is a specific representation of data from one or
23 more tables
Maximum number of columns that can be defined in
24 a view

The view will become invalid whenever the base


26 table is altered
27 what is true about inline views

For a view to be inherently updatable,which of the


28 following conditions must be met?

29 What are the restrictions on BEFORE trigger

30 What are the restrictions on AFTER trigger

31 What are the restrictions on INSTEAD OF triggers

32 How to know the last executed procedure?

33 What is mutating table error?


34 Which is not a oracle package?
The ----- returns the actual error message for the
35 last error encountered
36 A table can be created through a procedure

37 How we can create a table through procedure ?

38 Can we use a subquery in FOR clause?

How to disable multiple triggers on a table at a


39 time?
Cursor variable cannot be declared in a package
40 specification

41 What are the restrictions on Cursor variable?


42 What are the cursor attribute used in PL/SQl?
43 What are the components of PL/SQL blocks?
_______provides the record type that represents a
entire row of a table or view or columns selected in
44 the cursor
What will happen after the execution of COMMIT
45 statement?
46 Which all are the part of database trigger?
47 Which is not a triggering event
Triggering Constraint is specified using _______
48 clause

49 Which all are the different types of database trigger?


Is it possible to use transaction control statements in
50 database triggers?

51 Which of the follwing statements are true ?


What happens if a procedure that updates a column
of table X is called in a database trigger of the same
table ?
52
Which are the plsql statement used in Cursor
processing?
53
Name the tables where characteristics of Package,
54 procedure and functions are stored ?
The _____________
tells the compiler to assosiate
an exception with an oracle error.
55
is a
procedure of package DBMS which
allows to issue user_defined error
56 message
What are the modes of parameters that can be
passed to a procedure ?
57

What is the difference in calling functions and


58 procedure in a PL/SQL block
What is difference between a Cursor declared in a
procedure and Cursor declared in a package
59 specification
60 How to call packaged procedure from SQL *PLUS

61 How to call packaged function from SQL *PLUS


62 Which one is not a named system exception?
63 Which is not a pseudocolumns?

64 What is a nested subquery?

65 What is a correlated subquery?


Why use Truncate over Delete while deleting all
66 rows ?
What best describes the relationship between
indexes and SQL performance?
67
Which of the following is an important feature of
68 relational databases and SQL?

Which of the following is an important consideration


when tuning an SQL statement?
69

70 Which is a major problem with SQL?

71 Which statement is correct?


Which of the following statements about a role are
true
1)Privileges are assigned to a role using the grant
stmt.
2) A role can comprise a maximum of 100 privileges
3) A role is a named group of related
privileges,which can only be assigned to users.
4 )A role can be assigned to maximum of 1000
users
5) A user can be assigned several roles, and a
single role can be assigned toseveral users.
72 6) A roel is created using create role statement.
A user can be assigned several roles and a single
73 role can be granted to several users
74 What are the different types of privileges
75 MERGE command is a combination of?
You have created a function named My_fun in the
data base. Which of the following data dictionary
views will be used to see the names of the
procedures and functions that invoke the My_fun
76 function
The database contains a package named
my_pack.you wast to delete the package
specification from the database while retaining the
package body.which of the following statement will
77 accomplish this?

Database Contains a table audit_tab.You require to


create a trigger at the database level to ensure that
whenever a user logs on the database, his name
and current dates are inserted into audit_tab.
CREATE OR REPLACE TRIGGER aud_trigger
BEFORE LOGON DATABASE
BEGIN
INSERT INTO audit_tab VALUES
(USER,SYSDATE );
END;
78 Which statement is true about aud_trigger?
CREATE OR REPLACE TRIGGER audit_trigger
AFTER INSERT ON Employee
BEGIN
INSERT INTO employee_audit
VALUES(emp_id,:NEW.last_name,:NEW.first_name
);
END;
79 What will happen when this statement is executed?
Which of the following statement about LOB are
80 true?

81 How to display row number with the records


How to display a number value in words where
82 vriable sal is of type number?
What is maximum no of triggers applied to a single
83 table
What does the below statement does?
select * from emp where (rowid,1) in (select rowid,
mod(rownum,2) from emp);
84
85 Which date function returns a number value
Omitting the WHERE clause of an UPDATE or
DELETE statement has what effect?
86

87 Referential integrity refers to what?

What statement could you use in the WHERE clause


to select all the rows in a table where no price is
88 defined

When using an INSERT statement, data to be


inserted may come from which of the following?

89
90 Which of the following is not a aggregate functions?
What is the lifetime of a user-defined variable?
91
Which of the following commands can be used to
interrupt processing of a While loop?
92

93 What are the space requirements for views?

Which of the following best describes a situation in


94 which the statistics for a table would be misleading

what is the maximum size of the message that we can


95 give in dbms_output.putline();
96 How can we retrive multiple rows in PLSQL

Can you add not null column to a table already


97 containing data ?
A function can return more than one value. Is this
98 statement true?

Which statement is true about 'TABLE OF' in


99 PL/SQL

What is difference between %ROWTYPE and TYPE


100 RECORD?

101 The following are Oracle supplied packages


102 PLSQL is referred to as a
103 PLSQL block can contain the following
104 A PLSQL block cannot contain the below
105 What is the use of DBMS_OUTPUT
106 Which one of these is not a valid privelege
107 Every PLSQL statement is followed by a
108 PL/SQL commands are case sesitive
109 PLSQL blocks can be nested
110 Which of these is not a PLSQL keyword
111 Which symbol is used in assignment statement
112 How many rows the table DUAL has

113 VARCHAR2 data type is used to store


114 CHAR data type is used to store
115 RTRIM function is used to
116 LTRIM function is used to
117 TRIM function is used to
118 BINARY_INTEGER variables are stored using
119
Among NUMBER and BINARY_INTEGER data
types which one takes less space
Which exception is raised when we assign the
120
wrong type of value to a variable

121 The syntax for declaring a procedure

122 The syntax for declaring a function

123 Functional can have an OUT variable


124 Which of the does not return a value
What can you do to ignore the time portion of a
125
DATE variable
126
Which functions are useful when comparing case-
insenitive string comparisons
Operators of the same precedence level are
127
evaluated
128 Use of parentheses in complexe expressions
129 Comparison of NULL with any other value evaluates
130 Expression TRUE OR FALSE evaluates
131 IS NULL operator is used
132 Which of these are conversion functions
133 Converts either a number or a date to a character str
134 Expression TRUE AND NULL evaluates to
135 Expression TRUE OR NULL evaluates to
136 Condition X IN (1,2,3) is equallent to
137 Which is the right way of dealing with NULL values
138 TRUNC(SYSDATE,'YYYY') gives
139 TO_CHAR(SYSDATE,'Mon') results if the sysdate is
140 Which operator needs only one operand

141 Which is the right syntax for IF statement

142 The syntax for Loops

143 Does Oracle allow you to create your own functions


144 Can you call functions from any PL/SQL code
145 Syntax for GO TO statement

146 Syntax for While Loops

147 How many times must the WHILE loop execute


148 Which command is used to exit from a simple LOOP
149 Can you potentially write a WHILE loop that never en
150 What statement(s) allow you to abort the processing o

151 A Procedure is a

152 A stored procedure is


153 How do you drop a procedure
154 What is a recursive procedure

155 How do you recompile a package


156 Which of these are predefined exceptions
157 Which of the below is a DML statement
158 Which of the below is a DDL statement
159 DDL statements means
160 Which statement will implicitly issue a commit
161 PL/SQL table functions
162 PL/SQL table functions
163 What is the variable attribute you use to base a varia
164 What is a PLSQL record
165 Which of these are Pseudo columns
166 Name a few implicit cursor attributes
167 What are the types of cursors
168 Which attribute tells the cursor is already in use
169 Which attribute can tell the number of rows fetched so
170 Triggers are fired in response to the following events
171 The following are database privileges
172 Keyword DECLARE is used while defining
173 Why do we type / at the end of PLSQL block
174 Which command is used to display a line of text
175 Where does PL/SQL code execution take place
176
Oracle products such as Oracle Forms have the
capability to execute PL/SQL code at client side
Which of these is a fundamental unit of PL/SQL
177
programming
178 Which of the below is not a PL/SQL data type
179
What is the maximum size limit allowed for
VARCHAR2 variable in PL/SQL block
180 Number data type is used for declaring
181 Number data type allows maximum precision of
182 Precision in number data type specifies

183 Scale in number data type specifies

184 BINARY_INTEGER datatype is used for declaring


Which data type is used to store strings of byte-
185
oriennted data
186 Size of RAW data type in PL/SQL

187 Syntax for database triggers

188 Which of the below can be used in expression


While evaluating expressions, Oracle evaluates
189
operators with a higher precedence
190 Which among these operators has highest preceden
191 execute dbms_utility.compile_all
192 Which exception is raised when PL/SQL encounters an
193 Conversion of a number to a character string failes ra
Legal or not legal
194 DECLARE
emp_rec emp_rec_type
Legal or not legal
195 DECLARE
emp_last_name %type
Legal or not legal
DECLARE
196
TYPE emp_table is table of VARCHAR2(55);
emp_dept_table emp_table_type;
Difference between anonymous blocks and stored
197 procedures ?

Why use Truncate over Delete while deleting all


198
rows
199 How do you run Native Dynamic SQL
200 Which type_name
TYPE of the belowISisTABLE
not a predefined exception
OF element_type;
In the adove nested table
syntax,element_type can be PL/SQL datatype
201 except

Which all statements are true about REF CURSOR


A) The syntax of a REF CURSOR type should
include a ' RETURN ' clause
B) The cursor variable declared from a strong REF
CURSOR can be associated with queries whose result
sets match the number and datatype of the record
C) Cursor
structure after variablesclause
the RETURN declared from weak REF
at runtime
CURSORs can be associated with any query at
runtime
D) Cursor variables declared from strong
REF
E) CURSORs can be
The cursor associated
variable withfrom
declared any aquery
weak
at runtime
REF CURSOR can be associated with queries
whose result sets match the number and datatype
of the record structure after the RETURN clause at
202 runtime

203 Is it possible to use Commit/rollback in Exception ?


Is there any diff between the below two statements
a char(20) := 'name';
204 a Varchar(20) := 'name'; ?

What is the difference between using IS and AS


while creating a procedure, function package and
205 package body?
Functionality of Right OUTER JOIN is same as right
206 join. Is this statement true?

207 Which statement is true about EXISTS Usage?


In PL/SQL , we write select statement with INTO
208 clause, this mat returns which all exceptions??
Is it possible to have same name for package and
209 the procedure in a package

what is the order of execution if there is a statement


level and row level trigger on a same table? 1)
Before Statement level
2)After Statement level
3)Before Row level
4)After Row level

210
What will happen to an anonymus block,if there is
no statement inside the block?
211

Suppose I have 2 triggers on table T, tr1- a before


insert trigger & tr2- a before update trigger.
tr1 has update (T) statement inside body of tr1
and
tr2 has insert (T) statement inside body of tr2
Now, I'm tring to insert a row into T.
212 What will happen

You need to store currency data and you know that


data will always have two digits to the right of the
decimal points. However the number of digits to the
left of the decimal place will vary greatly. Which data
213 type would be most appropriate to store the data?
You need to update employee salaries if the salary
of an employee is less than 1000.The salary needs
to be
incremented by 10%. Use SQL*Plus substitution
variable to accept the employee number. Which
214 PL/SQL block successfully updates the salaries?

The employee table contains these columns.


LAST_NAME VARCHAR2(25) FIRST_NAME
VARCHAR2(25)
DEPT_ID NUMBER(9) You need to display the
names
of the employees that are not assigned to the
department. Evaluate this SQL statement.
SELECT last_name, first_nameFROM employee
WHERE
dept_id is NULL Which change should you make to
215 achieve the desired result?
Written a PL/SQL loop, you need to test if the
current FETCH was successful.Which SQL cursor
attribute would you use to
216 accomplish this task?

The structure of the DEPT table is as follows: NAME


NULL TYPE Deptno Not Null NUMBER(2) Dname
VARCHAR2(14) Loc VARCHAR2(13) Examine the
code Declare Type
dept_record_type is record (dno NUMBER, name
VARCHAR2(20)); dept_rec dept_record_type;
Begin
Select deptno, dname INTO dept_rec FROM dept
WHERE deptno=10; END Which statement displays
217 the name of selected department?
Evaluate this IF statement.
IF v_value>100 THEN
v_new-value:=2*v-value;
ELSIF v-value>200 THEN
v-new-value:=3*v-value;
ELSIF v-value>300 THEN
v-new-value:=4*v-value;
ELSE v-new-value:=5*v-value;
END IF
What would be assigned to v_new_value if
218 v_value=250?

How would you declare a PL/SQL table of records


219 to hold the rows selected from the EMP table?
You want to create a cursor that can be used
several times in a block. Selecting a different active
set each time that it is opened. Which type of cursor
220 do you create?

Which statement is true when writing a cursor


221 FORloop?

222 Which statement about implicit cursors is true?

Evaluate this PL/SQL block: DECLARE v-result


NUMBER(2); BEGIN DELETE
FROM employee
WHERE dep_id IN (10,20,30);
v-result:= SQL%ROWCOUNT;
COMMIT;
END;
What will be the value of v_result if no rows are
223 deleted?

Which two conditions in a PL/SQL block cause an


224 exception error to occur?
You need to create a PL/SQL program to insert
records into employee table.
Which block of code successfully uses the insert
225 command?

Evaluate this PL/SQL block.


BEGIN
FOR i IN 1..10 LOOP
IF I=4 OR I=6 THEN null;
ELSE
INSERT INTO test(result)
VALUES (I) ;
END IF;
COMMIT;
END LOOP;
ROLL BACK;
END.
How many values will be inserted into the TEST
226 table?

You attempt to query the database with this


command:
SELECT
dept_no,AVG(MONTHS_BETWEEN(SYSDATE,hire
-data))
FROM employee WHERE
AVG(MONTHS_BETWEEN(SYSDATE,hire_date))>
60
GROUP BY by dept_no
ORDER BY
AVG(MONTHS_BETWEEN(SYSDATE,hire_date));
227 Why does this statement cause an error?
In which section of a PL/SQL block is a user defined
228 exception waste?
Examine the code: SET SERVER OUTPUT ON
DECLARE v_char_val varchar2(100);
BEGIN v_char_val:= 'Hello
World', DBMS_OUTPUT.PUT_LINE(v_char_val);
END
SET SERVER OUTPUT OFF This code is stored in
a script file name "myproc.sql". Which statement
229 executes the code in the script file?

Examine this block F code


Set server output ON
Declare
X NUMBER;
V_SAL NUMBER;
V_found VARCHAR2(10) := 'TRUE'
Begin
X:=1;
V_SAL :=1000;
Declare
V_found VARCHAR2(10);
Y NUMBER;
Begin
IF (V_sal>500) THEN
V_found := 'YES';
END IF;
DBMS_OUTPUT.PUT_LINE('value f V_found is' ||
V_found);
DBMS_OUTPUT.PUT_LINE ('value f V_found is' ||
V_found);
Y:20;
END
DBMS_OUTPUT.PUT_LINE ('value f V_found is' ||
V_found);
DBMS_OUTPUT.PUT_LINE ('value f Y is' ||
TO_CHAR (Y);
END
Why does this code produce an error when
230 executed?

Which statement is valid within the executable


section
231 of Pl/SQL block?
In the declarative section of a PL/SQL block, you
created but did not initialize a number variable.
When the block executes what will be the initial
232 value of the variable?
When selecting data which statement is valid about
233 projection?

Structure of DEPT table is as follows:


Name Null Type
DEPTNO NOT NULL NUMBER(2)
DNAME VARCHAR2(14)
LOC VARCHAR2(13)
Examine the declaration section.
DECLARE
TYPE dept_table_type IS TABLE OF dept
%ROWTYPE
INDEX BY BINARY INTEGER
dept_table dept_table_type;
You need to assign LOC field in record 15 the value
of 'Atlanta'. Which PL/SQL
234 statement makes this assignment?
You need to change the job title Clerk to
Administrative Clerk
for all Clerks.
235 Which statement does this?

Given the executable section of a PL/SQL block


FOR employee_record IN Salary_Cursor Loop
employee_id_table (employee_id):=
employee_record.last_name;
END Loop
Close Salary_Cursor;
END;
236 Why does this section cause an error?

Examine this function: CREATE OR REPLACE


FUNCTION CALC_PLAYER_AVG (V_ID in
PLAYER_BAT_STAT.PLAYER_ID%TYPE)
RETURN NUMBER IS V_AVG NUMBER; BEGIN
SELECT HITS / AT_BATS INTO V_AVG FROM
PLAYER_BAT_STAT WHERE PLAYER_ID = V_ID;
RETURN (V_AVG); END; Which statement will
237 successfully invoke this function in SQL *Plus?
Which are true statements about
238 dependent objects?

CREATE OR REPLACE PRODECURE add_dept


(p_dept_name VARCHAR2 DEFAULT 'placeholder',
p_location VARCHAR2 DEFAULT 'Boston')
IS
BEGIN
INSERT INTO departments
VALUES (dept_id_seq.NEXTVAL, p_dept_name,
p_location);
END add_dept;
/
Which are valid calls to the add_dep procedure?
239

Which statements about packages


240 are true?
Which two programming constructs can be grouped
241 within a package?
Which statements describe the state of a package
variable after executing the package in which it is
242 declared?

Which code can you use to ensure that the salary is


not increased by more than 10% at a time nor is it
243 ever decreased?
Examine this code:
CREATE OR REPLACE PACKAGE bonus IS
g_max_bonus NUMBER := .99;
FUNCTION calc_bonus (p_emp_id NUMBER)
RETURN NUMBER;
FUNCTION calc_salary (p_emp_id NUMBER)
RETURN NUMBER;
END; /
CREATE OR REPLACE PACKAGE BODY bonus IS
v_salary employees.salary%TYPE;
v_bonus employees.commission_pct%TYPE;
FUNCTION calc_bonus (p_emp_id NUMBER)
RETURN NUMBER IS
BEGIN
SELECT salary, commission_pct INTO v_salary,
v_bonus
FROM employees WHERE employee_id =
p_emp_id;
RETURN v_bonus * v_salary;
END
calc_bonus FUNCTION calc_salary (p_emp_id
NUMBER) RETURN NUMBER IS
BEGIN SELECT salary, commission_pct INTO
v_salary, v_bonus FROM
employees WHERE employees RETURN v_bonus
* v_salary + v_salary;
END cacl_salary; END bonus; / Which statement is
244 true?

245 Which statement is valid when removing procedures?

You need to create a trigger on the EMP table that


monitors every row that is changed and places this
information into the AUDIT_TABLE.
246 What type of trigger do you create?

247 Which statements are true?


248 Which dictionary view track dependencies?

Given a function CALCTAX: CREATE OR


REPLACE FUNCTION calctax (sal NUMBER)
RETURN NUMBER IS BEGIN RETURN (sal * 0.05);
END; If you want to run the above function from the
249 SQL *Plus prompt, which statement is true?
What happens during the execute phase with
dynamic SQL for INSERT, UPDATE, and DELETE
250 operations?
What part of a database trigger determines the
251 number of times the trigger body executes?

Examine this code:


CREATE OR REPLACE FUNCTION
gen_email_name
(p_first_name VARCHAR2, p_last_name
VARCHAR2, p_id NUMBER)
RETURN VARCHAR2
is
v_email_name VARCHAR2(19);
BEGIN
v_email_home := SUBSTR(p_first_name, 1, 1) ||
SUBSTR(p_last_name, 1, 7) ||
'@Oracle.com';
UPDATE employees
SET email = v_email_name
WHERE employee_id = p_id;
RETURN v_email_name;
END;
You run this SELECT statement:
SELECT first_name, last_name
gen_email_name(first_name, last_name, 108)
EMAIL
FROM employees;
252 What occurs?
Which table should you query to determine when
253 your procedure was last compiled?
Examine this code: CREATE OR REPLACE
TRIGGER secure_emp BEFORE LOGON ON
employees BEGIN IF (TO_CHAR(SYSDATE, 'DY')
IN ('SAT', 'SUN')) OR (TO_CHAR(SYSDATE,
'HH24:MI') NOT BETWEEN '08:00' AND '18:00')
THEN RAISE_APPLICATION_ERROR (-20500,
'You may insert into the EMPLOYEES table only
during business hours.');
END IF;
END;
/
254 What type of trigger is it? `

Examine this package:


CREATE OR REPLACE PACKAGE discounts
IS
g_id NUMBER := 7829;
discount_rate NUMBER := 0.00;
PROCEDURE display_price (p_price NUMBER);
END discounts;
/
CREATE OR REPLACE PACKAGE BODY
discounts
IS
PROCEDURE display_price (p_price NUMBER)
IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Discounted '||
TO_CHAR(p_price*NVL(discount_rate, 1)));

END display_price;
BEGIN
discount_rate := 0.10;
END discounts;
/
Which statement is true?
255
CREATE OR REPLACE TRIGGER update_emp
AFTER UPDATE ON emp
BEGIN
INSERT INTO audit_table (who, dated)
VALUES (USER, SYSDATE);
END;
You issue an UPDATE command in the EMP table
that results in changing 10 rows.
How many rows are inserted into the
256 AUDIT_TABLE?

You want to retrieve the employee details from the


emp table and process them in
PL/SQL block. Which type of variable do you create
in the PL/SQL block to retrieve all the rows and
columns using a single select statement from the
257 emp table?

258 Which statements about packages are true?

When creating a function in SQL *Plus, you receive


this message:
"Warning: Function created with compilation errors."
Which command can you issue to see the actual
259 error message?
260 Which triggering events can cause a trigger to fire?
Examine this procedure:
CREATE OR REPLACE PROCEDURE
ADD_PLAYER1
(V_ID IN NUMBER, V_LAST_NAME VARCHAR2)
IS
BEGIN
INSERT INTO PLAYER (ID,LAST_NAME)
VALUES (V_ID, V_LAST_NAME);
COMMIT;
END;
This procedure must invoke the APD_BAT_STAT
procedure and pass a parameter.
Which statement, when added to the above
procedure will successfully invoke the
UPD_BAT_STAT
261 procedure?

262 Which statement about triggers is true?

You want to create a PL/SQL block of code that


calculates discounts on customer orders. -This code
will be invoked from several places, but only within
the program unit ORDERTOTAL.
What is the most appropriate location to store the
263 code that calculates the discounts?
Which type of argument passes a value from a
264 procedure to the calling environment?
You create a DML trigger. For the timing
information,
265 which is valid with a DML trigger?

You are about to change the arguments of the


CALC_TEAM_AVG function.
Which dictionary view can you query to determine
the names of the procedures and functions that
266 invoke the CALC_TEAM_AVG function?
267 A CALL statement inside the trigger body enables you
You need to remove the database trigger
BUSINESS_HOUR.
Which command do you use to remove the trigger in
268 the SQL *Plus environment?
How can you migrate from a LONG to a LOB data
type
269 for a column?

Examine this procedure:


CREATE OR REPLACE PROCEDURE
INSERT_TEAM
(V_ID in NUMBER, V_CITY in VARCHAR2
DEFAULT 'AUSTIN', V_NAME in
VARCHAR2)
IS
BEGIN
INSERT INTO TEAM (id, city, name)
VALUES (v_id, v_city, v_name);
COMMIT;
END
Which statements will successfully invoke this
270 procedure in SQL *Plus?

272 Which describe a stored procedure?


Examine this code:
CREATE OR REPLACE PROCEDURE add_dept
( p_name departments.department_name%TYPE
DEFAULT 'unknown',
p_loc departments.location_id%TYPE DEFAULT
1700)
IS
BEGIN
INSERT INTO departments(department_id,
department_name,
loclation_id)
VALUES(dept_seq.NEXTVAL,p_name, p_loc);

END add_dept;
/

You created the add_dept procedure above, and


you now invoke the procedure in SQL *Plus.
273 Which is not valid invocations?

274 Which is not a valid way to minimize dependency fail

275 Which dopes the INSTEAD OF clause in a trigger ide


FUNCTION calc_tax (p_sal NUMBER) RETURN
NUMBER; END manage_emps;
/ CREATE OR REPLACE PACKAGE BODY
manage_emps IS PROCEDURE update_sal
(p_raise_amt NUMBER) IS BEGIN UPDATE emp
SET sal = (sal * p_raise_emt) + sal WHERE empno
= v_id; END; PROCEDURE insert_emp (p_deptno
NUMBER, p_sal NUMBER) IS BEGIN INSERT
INTO emp(empno, deptno, sal) VALYES(v_id,
p_depntno, p_sal); END insert_emp; PROCEDURE
delete_emp IS BEGIN DELETE FROM emp
WHERE empno = v_id; END delete_emp;
PROCEDURE update_emp IS v_sal NUMBER(10,
2); v_raise NUMBER(10, 2); BEGIN SELECT sal
INTO v_sal FROM emp WHERE empno = v_id; IF
v_sal < 500 THEN v_raise := .05; ELSIP v_sal <
1000 THEN v_raise := .07; ELSE v_raise := .04;
END IF; update_sal(v_raise); END update_emp;
FUNCTION calc_tax
(p_sal NUMBER)
RETURN NUMBER
IS
BEGIN
RETURN p_sal * tax_rate;
END calc_tax;
END manage_emps;
/
What is the name of the private procedure in this
package?
276

277 What can you do with the DBMS_LOB package?


Examine this code:
CREATE OR REPLACE PACKAGE comm_package

IS
g_comm NUMBER := 10;
PROCEDURE reset_comm(p_comm IN NUMBER);
END comm_package;
/
User Jones executes the following code at 9:01am:
EXECUTE comm_package.g_comm := 15
User Smith executes the following code at 9:05am:
EXECUTE comm_paclage.g_comm := 20
278 Which statement is true?
279 Which statement removes the function?

Examine this procedure:


CREATE OR REPLACE PROCEDURE
UPD_BAT_STAT
(V_ID IN NUMBER DEFAULT 10, V_AB IN
NUMBER DEFAULT 4)
IS
BEGIN
UPDATE PLAYER_BAT_STAT
SET AT_BATS = AT_BATS + V_AB
WHERE PLAYER_ID = V_ID;
COMMIT;
END;
Which two statements will successfully invoke this
280 procedure in SQL *Plus?

Examine this code: CREATE OR REPLACE


PROCEDURE audit_action

(p_who VARCHAR2) AS BEGIN INSERT INTO


audit(schema_user) VALUES(p_who); END
audit_action; / CREATE OR REPLACE TRIGGER
watch_it AFTER LOGON ON DATABASE CALL
audit_action(ora_login_user) / What does this
trigger do?
281
Examine the declaration section:
DECLARE
CURSOR emp_cursor(p_deptno NUMBER, p_job
VARCHAR2)
IS SELECT EMPNO, ENAME
FROM EMPWHERE DEPTNO=p_deptno
AND JOB=p_job;
BEGIN
...
282 Which statement opens the cursor successfully?
283 The OLD and NEW qualifiers can be used in which typ

284 Which statement is true?

Examine the trigger:


CREATE OR REPLACE TRIGGER Emp_count
AFTER DELETE ON Emp_tab
FOR EACH ROW
DELCARE
n INTEGER;
BEGIN
SELECT COUNT(*)
INTO n
FROM Emp_tab;
DBMS_OUTPUT.PUT_LINE(' There are now ' || n||
' employees,');
END;
This trigger results in an error after this SQL
statement is entered:
DELETE FROM Emp_tab WHERE Empno = 7499;
285 How do you correct the error?

286 What is true about stored procedures?


The creation of which database objects will
287 not cause a DDL trigger to fire?
Which two program declarations are
288 correct for a stored program unit?

You need to implement a virtual private database


(vpd). In order to have the vpd functionality, a
trigger is required to fire when every user initiates a
session in the database.
What type of trigger needs to be created?
289

You have a row level BEFORE UPDATE trigger on


the EMP table. This trigger contains a SELECT
statement on the EMP table to ensure that the new
salary value falls within the minimum and maximum
salary for a given job title. What happens when you
290 try to update a salary value in the EMP table?

Examine this code:


CREATE OR REPLACE STORED FUNCTION
get_sal
(p_raise_amt NUMBER, p_employee_id
employees.employee_id%TYPE)
RETURN NUMBER

IS
v_salary NUMBER;
v_raise NUMBER(8,2);
BEGIN
SELECT salary
INTO v_salary
FROM employees
WHERE employee_id = p_employee_id;
v_raise := p_raise_amt * v_salary;
RETURN v_raise;
END;
291 Which statement is true?

You need to disable all triggers on the


EMPLOYEES table.
292 Which command accomplishes this?

293 An internal LOB is _____.


Examine this code:
CREATE OR REPLACE FUNCTION
calc_sal(p_salary NUMBER)
RETURN NUMBER
IS
v_raise NUMBER(4,2) DEFAULT 1.08;
BEGIN
RETURN v_raise * p_salary;
END calc_sal;
/
Which statement accurately call the stored function
294 CALC_SAL?

This statement fails when executed:


CREATE OR REPLACE TRIGGER
CALC_TEAM_AVG
AFTER INSERT ON PLAYER
BEGIN
INSERT INTO PLAYER_BATSTAT (PLAYER_ID,
SEASON_YEAR,AT_BATS,HITS)
VALUES (:NEW.ID, 1997, 0,0);
END;
To which type must you convert the trigger to
295 correct the error?
Examine this code: CREATE OR REPLACE
PACKAGE metric_converter IS c_height
CONSTRAINT NUMBER := 2.54; c_weight
CONSTRAINT NUMBER := .454; FUNCTION
calc_height (p_height_in_inches NUMBER)
RETURN NUMBER; FUNCTION calc_weight
(p_weight_in_pounds NUMBER) RETURN
NUMBER; END; / CREATE OR REPLACE
PACKAGE BODY metric_converter IS FUNCTION
calc_height (p_height_in_inches NUMBER)
RETURN NUMBER IS BEGIN RETURN
p_height_in_inches * c_height; END calc_height;
FUNCTION calc_weight (p_weight_in_pounds
NUMBER) RETURN NUMBER IS BEGIN RETURN
p_weight_in_pounds * c_weight END calc_weight
END metric_converter; / CREATE OR REPLACE
FUNCTION calc_height (p_height_in_inches
NUMBER) RETURN NUMBER IS BEGIN RETURN
p_height_in_inches * metric_converter.c_height;
296 END calc_height; / Which statement is true?

297 What is a condition predicate in a DML trigger?


Which command must you issue to allow users to
access the UPD_TEAM_STAT trigger on the TEAM
298 table?
When creating a function, in which section will you
299 typically find the RETURN keyword?
In which section of a PL/SQL block is a user defined
300 exception raised?

301 Which statement is true about nesting blocks?


Examine Code:
1 DECLARE
2 i NUMBER := 0;
3 v_date DATE ;
4 BEGIN
5 i := i + 1;
6 LOOP
7 i := v_date + 5;
8 i := i + 1;
9 EXIT WHEN i = 5;
10 END LOOP;
11 END
You have encountered the unexpected results when
above block of code is executed.
How can u trace the values of counter variable i and
date variable v_date in SQL*
302 PLUS environment?

Examine code: SET SERVEROUTPUT ON


DECLARE v_name emp.ename%TYPE;
v_num NUMBER; v_sal NUMBER(8,2); BEGIN ---
This code displays salaries if larger than 10,000.
SELECT ename, sal INTO v_name, v_sal FROM
emp WHERE empno=101; IF(v_sal.GT.10000)
THEN
DBMS_OUTPUT.PUT_LINE('Salary is '||' v_sal || 'for
employee' || v_name); END IF; END SET
SERVER OUTPUT OF This statement produces a
compilation error when above PL/SQL block is
303 executed?

You are a user of PROD database which contains


over 1000 tables and you need to
determine the number of tables you can access.
Which data dictionary view could you query to
display
304 this information?

You query the database with this


command.SELECT last_name, first_nameFROM
employeeWHERE SALARY IN SELECT salary
FROM employee WHERE dept_no=3 OR
dept_no=5);
305 Which values are displayed?
Which operator is not appropriate in the joined
condition of none equijoin select
306 statement?
What should you do after each fetch statement in
307 the PL/SQL block?
Which SELECT statement would you use in a
PL/SQL block to query the employee table and
retrieve the last name and salary of the employee
308 whose ID is 3?

The structure of the DEPT table as: Name Null?


Type
DEPT NO Not NULL Number(25)
DNAME VARCHAR2(14)
LOC VARCHAR2(13).
Examine the declaration section.
DECLARE TYPE dept_record_type is RECORD
(dno NUMBER,
name VARCHER(20));
dept_rec dept_record_type;
How do you retrieve an entire row of the DEPT table
using the DEPT-REC
309 variable?

Examine the code: DECLARE. CURSOR


emp_cursor ISSELECT ename,deptno
FROM emp; emp_rec emp_cursor %ROWTYPE
BEGIN OPEN emp_cursor
LOOP
FETCH emp_cursor
INTO emp_rec
EXIT WHEN emp_cursor NOT FOUND;
INSERT INTO temp_emp(name'dno)
VALUES(emp_rec.ename,emp_rec deptno);
END LOOP;
CLOSE emp_cursor;
END;
Using a cursor FOR loop,which PL/SQL block
310 equivalent to the above code?

Under which situation it is necessary to use an


311 explicit cursor?
Which data dictionary view contains the definition of
312 a view?
Evaluate this PL/SQL block:
for I in 1..5 IF i=1 THEN NULL;
ELSIF i=3 THEN COMMIT;
ELSIF i=5 THEN ROLLBACK;
ELSE INSERT INTO test (results);
VALUES(i);
END IF;
END LOOP;
COMMIT;
END;
How many values will be permanently inserted into
313 the TEST table?
A collection is an ordered group of elements
314 of --------------------------
315 Which is a pl/sql collection type
316 Index by table is also known as
Index by table let you lok up elements using -------
317 for subscript values
Nested table let you lok up elements using -------
318 for subscript values
Which PL/SQL collection type will use sequential
319 numbers as subscript types
Which PL/SQL collection type will hold fixed number
320 of elements
321 PL/SQL collection types can be declared in
Which PL/SQL data type can be stored as a column
322 in a data base table

323 Nested Tables cannot use the following data types


which PL/SQL collection type does not need
324 Constructors
325 Which PL/SQL collection needs a constructor
If the subscript of a PL/SQL collection is null,or is
not convertable to the right datatype then it throws
326 the following exception
If the subscript of a PL/SQL collection refers to an
327 uninitialized element, PL/SQL raises
328 If the collection is atomically null, PL/SQL raises
Associative arrays cannot use the following
329 collection methods
330 Which collection method is a procedure
331 Which collection method is a function
Which collection method can be applied to
332 automatically null collections
Which collection method returns TRUE if the nth
333 element in a collection exists
Which Syntax is correct for Counting the elements
334 in a PL/SQL collection
which Pl/SQL collection method will return NULL for
335 nested tables and associative arrays

which PL/SQL collection method returns the index


336 number that precedes index n in a collection
337 Subscript range for nested tables is
338 Subscript range for varrays is
Subscript range for associative arrays with numeric
339 key

340 Which is allowed for a PL/SQL collections


341 Pl/SQL collections cannot appear in ----------list
LIMIT returns the maximum number of elements
that the collection can contain for which Pl/SQL
342 collection type
Which PL/SQL collection method returns the
343 smallest Index number in a collection
Which PL/SQL collection method returns the largest
344 index number in a collection
If the collection is empty First and Last Pl/SQL
345 collection methods return
Which PL/SQL method returns the index number
346 that succeeds index n.
Which PL/SQL method is used to remove one
347 element from the end of a collection
Which PL/SQL method is used to remove n
348 elements from the end of a collection
Which PL/SQL method is used to remove all
349 elements from a collection
Which PL/SQL method removes the nth element
350 from an associative array with a numeric key
OPTION A OPTION B

1 2
There is no absolute limit to the total
ANS)Set OPEN_CURSORS parameter in number of cursors one session can
initialization parameters have open at one time

ANS)50 25

2,4 2,3,4

ANS)PMON SMON

PMON SMON

ANS)SYSTEM tablespace Temporary tablespace

1 2
You do not have the UPDATE object ANS) Scott does not have the UPDATE
privilege on the EMP_SAL table. object privilege on the EMP_SAL table

ANS)TRUE 0

ANS)A & D A,B,D

ANS)Object type Attribute

Declare(mandatory) Begin Declare(mandatory)


(mandatory) …... sql stmts Begin (mandatory) …... sql stmts
……plsql stmts ……plsql stmts
Exception(mandatory) End; Exception(optional) End;
(mandatory) (mandatory)
Only TRUE or FALSE can be assigned
Variable must be declared before the usage to BOOLEAN type of variable

Function can be called as a part of a


A functions must returns a value. expression

ANS)TRUE 0
By using block labels, you can give a
Anonymous blocks don't have names under name to your block for the duration of
which they can be stored in the database its execution, using PL/SQL labels .

ANS)Triggers Functions

0 ANS)TRUE

BEFORE UPDATING SOME


PERSON(S)
BEFORE UPDATING SOME
PERSON(S)
BEFORE UPDATING SOME
PERSON(S)
BEFORE UPDATING SOME
PERSON(S)
ANS)BEFORE UPDATING SOME BEFORE UPDATING SOME
PERSON(S) 5 Rows PERSON(S) 5
Updated Rows Updated

DROP trigger_name; ANS)DROP TRIGGER trigger_name;

PRIMARY KEYS UNIQUE KEY

Synonym ANS)Views

1000 512

ANS)TRUE 0
Inline view is a subquery that appears in the Inline view is enclosed in parenthesis
from clause of the select statement and may be given an alias name.

if an inherently updatable view contains


pseudocolumns or expressions, then
you cannot update base table rows with
an UPDATE statement that refers to
Each column in the view must map to a any of these pseudocolumns or
column of a single table expressions

You cannot specify a BEFORE trigger on a You cannot perform DML with BEFORE
view or an object view trigger
You cannot specify an AFTER trigger on a You cannot write either the :OLD or
view or an object view the :NEW value.
You can read both the :OLD and
INSTEAD OF triggers are valid only for the :NEW value, but you cannot write
views. either the :OLD or the :NEW value.

ANS)Select timestamps,owner,obj_name Select timestamps,owner,obj_name


from dba_audit_trial; from dba_objects;

Occurs whena trigger is disabled This occurs when a table is updated


ANS)DBMS_OUT DBMS_PIPE

SQLERROR SQLCODE
1 0

EXECUTE SQL 'CREATE TABLE ANS)EXECUTE IMMEDIATE 'CREATE


table_name AS query'; TABLE table_name AS query';
ANS)Yes, Instead of a cursor we can use No, We cannot use subquery in FOR
subquery in the FOR clause clause

ANS)ALTER TABLE table_name


ALTER TABLE table_name DISABLE; DISABLE ALL TRIGGERS;

ANS)TRUE 0
Cannot use comparision operators to
test cursor variable for
Cannot assign NULL to curosr variable equality,inequality or nullity
%ROWCOUNT %CURSOROPEN
Declarative Part Definition Part

ANS)%ROWTYPE %TYPE
The cursor having query as SELECT .... The cursor having query as SELECT....
FOR UPDATE gets closed after does not get closed even after
COMMIT/ROLLBACK COMMIT/ROLLBACK.
Triggering event Triggering action
INSERT DELETE

ANS)WHEN FOR EACH ROW

Row-level triggers Statement level triggers

ANS)NO YES

For triggers related to INSERT only


NEW.column_name values only
available.

For triggers related to DELETE only


OLD.column_name values only available.

ANS)Mutation of tables occurs Trigger is executed successfully

CURSOR Cursor_name OPEN Cursor name

User_objects user_source

ANS)PRAGMA_EXCEPTION_INIT EXCEPTION

PRAGMA_EXCEPTION_INIT EXCEPTION

IN OUT
Procudute is called as a part of an ANS)Procedure is called as plsql
expression . Functions are called as a plsql statement.Function is called as a part of
statement an expression

Cursor defined in package specification is Cursor defined in a procedure is local to


global that procedure
Variable a NUMBER;
EXCECUTE
EXCECUTE package_name.procedure,if package_name.procuder(:a); , if the
procedure doesnot have any in,in-out procedure have a out or inout
p[arameters. parameter of type NUMBER

Execute package_name.function; Return package_name.function


NO_DATA_FOUND DUP_VAL_ON_INDEX
ROWNUM ROWID
It's a subquery in the FROM clause with an
alias that can be used as a view within the ANS)The subquery used in WHERE
SQL statement clause

It's a subquery in the FROM clause with an


alias that can be used as a view within the
SQL statement The subquery used in WHERE clause

When truncate is used, Triggers are not fired It deallocates space

Indexes are used to make table


Indexes are only used in special cases storage more efficient

ANS)Independence of table relationships High speed of SQL

The number of CPUs on the server The degree of parallelism on the


tables

SQL syntax is too difficult for non-


SQL cannot support object-orientation computer professionals to use

GRANT UPDATE ON CUSTOMER ANS)GRANT UPDATE (title,address)


(title,address) TO ANDREW; ON CUSTOMER TO ANDREW;
Option 1,2,3 Option 2,5,6

ANS)TRUE 0
Object privilege Role privilege
ANS)INSERT & UPDATE INSERT & DELETE

USER_DB_LINKS ALL_DEPENDENCIES

ANS)You cannot accomplish this DROP package_specification My_pack;

ANS)It’s a invalid trigger It’s a DDL Trigger


The statement will fail because the
NEW qualifier cannot be prefixed with
The trigger wil created successfully colon.
LOB can be stored inside or outside a LOB represnts a datatype used to store
datasase large,unstructured data
ANS)using ROWNUM in the select
Using ROWID in the select statement statement

ANS)TO_CHAR ( TO_DATE(sal,'j') , 'JSP' ) TO_CHAR(sal)

100 10

ANS)Dispalys odd number of records Give runtime error


ADD_MONTHS ANS)MONTHS_BETWEEN

The query returns an error because the


ANS)All rows in the specified table are affecte WHERE clause is required.

The enforced uniqueness of a column in


The enforced uniqueness of a row in a table a table

WHERE price IS NOT NULL WHERE price IS < 0

The VALUES clause A stored procedure


SUM ANS)ABS

ANS)Duration of the script Duration of the statement block


BREAK HALT

Views require as much space as all the tables Views require as much space as would a
they are created from. table that presented the same data.

Deleting all of the records of a specific


Random rows in the table have been deleted gender

ANS)the maximum output is determined


by the size you specified in
dbms_output.enable(<size>). 255bytes
BULK COLLLECT REF CURSOR
ANS)Yes,we can add a not null constraint to
a column, but already existing row should
have a data for that column.
No
ANS)YES, function can return more
NO than one value using ref cursor

ANS)Table of is use to define a collection


type. A variable declared based on TABLE
OF data type is called cursor variable.

ANS)% ROWTYPE is to be used


whenever query returns a entire row of
a table or view.
TYPE rec RECORD is to be used
whenever query returns columns of
different
table or views and variables.

No difference

DBMS_OUTPUT DBMS_SQL
ans) block structured language unstructed langugage
variable declarations program code
other PL/SQL blocks error handlers
To handle errors ans) to display the output
CREATE TYPE CREATE TRIGGER
delimeter quote
Yes ans) No
ans) Yes No
BEGIN END
= ans) :=

No rows Multiple

ans) Variable length character strings Character string with 2 bytes size

Character data types ans) Fixed length character strings


elimiate leading spaces ans) eliminate trailing spaces
ans) elimiate leading spaces eliminate trailing spaces

elimiate leading spaces eliminate trailing spaces

same as number data type ans) binary format

NUMBER BINARY_INTEGER

ILLEGAL WRONG_DATA_TYPE

PROCEDURE <name> PROCEDURE <name> IS


BEGIN BEGIN
<program code> <program code>
END END

FUNCTION <name> RETURN <datatype> ans) FUNCTION <name> RETURN


DECLARE <datatype> IS
BEGIN BEGIN
<program code> <program code>
END END

ans) No Yes

FUNCTION PROCEDURE

ans) TRUNC TRIM

LOWER UPPER

RIGHT to LEFT ans) LEFT to RIGHT

is necessary not permitted

ans) TRUE 0
0 ans) TRUE
ans) when checking for NULL values not a valid command
TO_DATE TO_NUMBER
ans) TO_CHAR TO_DATE
1 0
ans) TRUE 0
X=1 AND X=2 AND X=3 X BETWEEN 1 AND 3
x=NULL ans) x IS NULL
ans) year last two digits of the year
JAN ans) Jan
binary ans) unary
ans) IF <condition> THEN IF <condition> THEN
<program_code> <program_code>
ELSE ELSE
<program_code> <program_code>
END IF; END;
FOR loop_index ans) FOR loop_index IN
low_value..high_value low_value..high_value
LOOP LOOP
<program_code <program_code
END LOOP; END LOOP;
ans) Yes No
ans) Yes No
GO TO lable_name ans) GOTO label_name
WHILE <condition is TRUE> WHILE <condition is TRUE>
LOOP LOOP
<statements> <statements>
END LOOP; ENDLOOP;

Atleast once ans) might never have to execute

EXIT EXIT WHEN


0 ans) TRUE
EXIT EXIT WHEN
ans) logically grouped set of SQL and
logically grouped set of database
PL/SQL statements that perform a specific
functions that perform a specific task
task

ans) stored in the database and compiled stored in the database as uncomiled

using a replace command ans) using drop procedure command

a procedure that goes into infinite loop a procedure that always returns 1
ALTER PACKGE <name> compile
ALTER PACKGE <name> compile body
package
no_data_found too_many_rows
INSERT UPDATE
COMMIT ROLLBACK
ans) Data definition language Data dictionary language
DELETE INSERT
COUNT EXISTS
last next
ans) %type %rowtype

It is a dynamic variable ans) variable with the type record

ROWNUM NEXTVAL
%FOUND %ROWCOUNT
implict explicit
ans) isopen %found
%count ans)%rowcount
A row is inserted into a table A row in a table is updated
CREATE PROCEDURE CREATE REDOFILES
ans) anonymous block procedure

to compile the code does not have any meaning

ans) DBMS_OUTPUT.PUT_LINE DBMS_OUTPUT.GET_LINE


Server Client

No ans) Yes

variable function

VARCHAR2 NUMBER

ans) 32767 2000

fixed point numbers floading pointing number


There is no limit 108 demimal digits
ans) how many digits are used to represent
where the decimal point is
the number
how many digits are used to represent the
ans) where the decimal point is
number

ans) signed integer variables unsigned integer variables

LONG ans) RAW

ans) 32767 255

CREATE OR REPLACE TRIGGER CREATE OR REPLACE


<trigger_name> <trigger_name>
{BEFORE|AFTER} verb_list ON {BEFORE|AFTER} verb_list ON
<table_name> <table_name>
[FOR EACH ROW] [FOR EACH ROW]
<variable list> <variable list>
BEGIN BEGIN
<program_code> <program_code>
END END

PROCEDURE ans) FUNCTION

ans) FIRST LAST

AND BETWEEN
compiles invalid packages compiles packages in dbms_utility
ans) program_error internal_error
value_error ans) invalid_number

ans) Not legal because emp_rec_type must Not legal because emp_rec_type must
be declared prior to this declaration be declared after this declaration

Not legal because it should include table ans) Not legal because it should include
reference table and column reference

Legal because we are delaring a table


Not legal because the table name is missing
type variable

Anonymous block is compiled only when it is ans) stored procedure is compiled only
called when it is called

truncate has an implicit commit it de allocates space

ans) use “Execute immediate”


use "dbms_execute"

dup_val_on_index not_logged_on

Binary_interger Varchar2

A,B,C ANS)B,C

ANS)YES NO
ANS)In Char type spaces will be
padded after 'name' upto max length
No difference. 20.in Varchar spaces will not be padded

ANS)There absolutely no difference Using IS will throw error

No ANS)Yes
the outer query is executed first and then the inner query is executed first and
inner query is excecuted for each value of then outer query is excecuted for each
outer query value of inner query

NO_DATA_FOUND TOO_MANY_ROWS

ANS)Yes No

1,2,3,4 ANS)1,3,4,2

Statement Comopiled successfully.but


ANS)Compilation error gives run time error

Trigger tr1 is fired and the table T is update ANS)will get a mutating table error

ANS)NUMBER NUMBER(T)
Declare V_sal emp.sal % TYPE;
Begin SELECT Sal INTO V_sal FROM Declare V_sal emp.sal % TYPE;
emp WHERE empno = and P_empno; Begin SELECT Sal INTO V_sal FROM
IF (V_Sal&lt;1000) THEN emp WHERE empno = and P_empno;
UPDATE emp INTO Sal := Sal*1.1 IF (V_Sal&lt;1000) THEN
WHERE empno = and P_empno; SAL := SAL * 1.1;
END IF;END; END IF;END;

Create an outer join. Change the column in the where conditio

SQL % ISOPEN SQL % ROWCOUNT

DBMS_OUTPUT.PUT_LINE (name); DBMS_OUTPUT.PUT_LINE (dname);


250 ANS)500

BEGIN
TYPE emp-table is TABLE of emp
DECLARE %ROWTYPE
emp-table is TABLE of emp%ROWTYPE. emp-table emp-table-type;

A cursor FOR loop. A multiple selection cursor.

You must explicitly fetch the You must explicitly open the cursor
rows within a cursor FOR loop. prior to the cursor FOR loop.

ANS)Implicit cursors are declared


Implicit cursors are declared implicitly implicitly for all the DML and SELECT
only for DML statements. statements.

ANS)0 1

Select statement does not Select statement returns more


return a row. than one row.
DECLARE
v_hiredate DATE:=SYSDATE:
BEGIN DECLARE
INSERT INTO emp(empnp, ename, hiredate, v-hiredate DATE:=SYSDATE:
deptno) BEGIN
VALUES(empno_sequence.nextval, 'and INSERT INTO
name',v_hiredate and deptno) emp(empnp,ename,hiredate,deptno)

0 4

A select clause cannot contain ANS)A where clause cannot be used to


a group function. restrict groups.

Heading ANS)Executable
Myproc.sql RUN myproc,sql

Variable V_found is declared at


The value f V_found cannot be YES. more than one location.

BEGIN WHEN NO_DATA_FOUND THEN


emp_rec emp%ROWTYPE DBMS_OUTPUT.PUT.LINE('No records
END; found');
0 ANS)NULL
Projection allows due to choose ANS)Projection allows due to
rows. choose columns.

dept_table.loc.15 := 'Atlanta'; dept_table[15].loc := 'Atlanta';

UPDATE emp
UPDATE emp Job := 'Administrative Clerk' WHERE
SET job = 'Administrative Clerk'; UPPER (job) = 'Clerk';

The cursor needs to be opened. Terminating conditions are missing.

ANS)SELECT
CALC_PLAYER_AVG(PLAYER_ID) FROM
PLAYER_BAT_STAT; EXECUTE CALC_PLAYER_AVG(31);
An object with status of invalid All schema objects have a status that
cannot be a referenced object. is recorded in the data dictionary.

add_dept; add_dept('Accounting');

Packages can be nested. You can pass parameters to packages.

Cursor Constant

ANS)It persists across transactions It persists from session to session


within a session. for the same user.

ANS)CREATE OR REPLACE
TRIGGER check_sal
BEFORE UPDATE OF sal ON emp
FOR EACH ROW
WHEN (new.sal < old.sal OR
new.sal > old.sal * 1.1)
BEGIN
RAISE_APPLICATION_ERROR ( -
ALTER TABLE emp ADD 20508, 'Do not decrease
CONS TRAINT ck_sal CHECK (sal salary not increase by more than 10%');
BETWEEN sal AND sal*1.1); END;
ANS)You can call the
You can call the BONUS.CALC_SALARY BONUS.CALC_SALARY packaged
packaged function from an INSERT function from
command against a SELECT command against the
the EMPLOYEES table. EMPLOYEES table

Use a drop procedure statement to drop


a procedure that is part of a package.
ANS)Use a drop procedure statement to Then recompile the package
drop a standalone procedure. specification

ANS)FOR EACH ROW trigger on the EMP


table. Statement-level trigger on the EMP table.
If errors occur during the compilation of
a trigger you can go into SQL *Plus and
If errors occur during the compilation of a query the USER_TRIGGERS data
trigger, the trigger dictionary view to see the compilation
is still created. errors.
USER_SOURCE UTL_DEPTREE

You need to execute the command You need to execute the command
CALCTAX(1000);. EXECUTE FUNCTION calctax;.

The validity of the SQL statement


The rows are selected and ordered. is established

ANS)Trigger type Trigger body

ANS)The statement fails because


Employee 108 has his email name updated functions called from SQL expressions
based on the return result of the function. cannot perform DML

USER_PROCEDURES USER_PROCS
DML trigger INSTEAD OF trigger

The value of DISCOUNT_RATE is set


The value of DISCOUNT_RATE always to 0.10 each time the package is
remains 0.00 in a session. invoked in a session.
ANS)1 10

PL/SQL record. %ROWTYPE variable


ANS)The specification and body of the The specification and body of the
package are stored separately in the package are stored together in the
database database

SHOW FUNCTION_ERROR SHOW USER_ERRORS


A specific error or any errors occurs A database is shut down or started up.
EXECUTE UPD_BAT_STAT(V_ID); ANS)UPD_BAT_STAT(V_ID);

You use an application trigger to fire ANS)You use a database trigger to fire
when a DELETE statement occurs when an INSERT statement occurs.

ANS)A stored procedure on the server. A block of code in a PL/SQL library.

VARCHAR2 BOOLEAN

DURING INSTEAD

USER_PROC_DEPENDS ANS)USER_DEPENDENCIES
A package A stored function
ANS)DROP TRIGGER business_hour; DELETE TRIGGER business_hour;

Use the
Use the DBMS_MANAGE_LOB.MIGRATE UTL_MANAGE_LOB.MIGRATE
procedure. procedure

EXECUTE EXECUTE INSERT_TEAM


INSERT_TEAM (3, 'LONGHORNS'); (3, V_NAME=>'LONGHORNS',
V_CITY=>'AUSTIN');

ANS)A stored procedure has three


parts:
A stored procedure is a type of PL/SQL the specification, the body, and the
subprogram that performs an action. exception handler part.
ANS)EXECUTE add_dept(p_loc=>2500) EXECUTE add_dept('Education', 2500)

ANS)Specifying schema names when


Querying with the SELECT * notification. referencing objects.

The view associated with the trigger The table associated with the trigger
CALC_TAX INSERT_EMP

Use the DBMS_LOB.WRITE procedure to Use the DBMS_LOB.BFILENAME


write data to a BFILE function to locate an external BFILE.
g_comm has a value of 15 at 9:06am ANS)g_comm has a value of 15 at
for Smith. 9:06am for Jones.
ANS)DROP FUNCTION gen_email_name; REMOVE gen_email_name;

EXECUTE UPD_BAT_STAT; UPD_BAT_STAT(V_AB=>10, V_ID=>31);

The trigger records an audit trail The trigger marks the user as logged on
when a user makes changes to the to the database before an audit
database. statement is issued.
OPEN emp_cursor. OPEN emp_cursor('clerk',10);
Row level DML trigger ANS)Row level application trigger

Stored functions do not permit calculations


that involve database links in a distributed Stored functions can be called from the
environment. SELECT and WHERE clauses only.

ANS)Change the trigger to a statement-


Remove the DBMS_OUTPUT statement level trigger by removing FOR EACH
because it is not allowed in a trigger. ROW
A stored procedure is named PL/SQL
A stored procedure uses the DELCLARE block with at least one
keyword in the procedure specification to parameter declaration in the procedure
declare formal parameters. specification.

ANS)Synonyms Index
CREATE OR REPLACE PROCEDURE ANS)CREATE OR REPLACE
tax_amt FUNCTION tax_amt
(p_id NUMBER) (p_id NUMBER)
RETURN NUMBER RETURN NUMBER

DML trigger ANS)System event trigger

The trigger fails because it needs


to be a row level AFTER UPDATE
The trigger fires successfully. trigger.

This statement creates a stored This statement returns a raise amount


procedure named get_sal. based on an employee id.

ALTER employees DISABLE


ALL TRIGGERS; ALTER TRIGGERS ON TABLE employee

A table. ANS)Stored in the database.


INSERT calc_sal(salary) INTO
UPDATE employees (calc_sal(salary)) employees
SET salary = salary * calc_sal(salary); WHERE department_id = 60;

ANS)Row Statement
ANS)If you remove the package If you remove the package body, then
specification, then the package body and the the package specification and the stand
stand alone stored function CALC_HEIGHT alone stored function CALC_HEIGHT
are removed. are removed
A conditional predicate means you use
A conditional predicate allows you to the NEW and
specify a WHEN-LOGGING-ON condition in OLD qualifiers in the trigger body as a
the trigger body. condition.

ANS)GRANT SELECT, INSERT, UPDATE, GRANT SELECT, INSERT, UPDATE,


DELETE DELETE
ON TEAM TO PUBLIC; ON UPD_TEAM_STAT TO PUBLIC;

HEADER only DECLARATIVE

Heading. ANS)Executable

Variable name must be unique


between blocks. ANS)A variable defined in the outer
block is visible in the inner blocks.
By inserting the statement
DBMS_OUTPUT.PUT_LINE (i ,
By setting SQL* PLUS session v_date);
variable DEBUGGER=TRUE Between lines 8-9

v_num NUMBER; v_name emp.ename%TYPE;

USER_OBJECTS. ANS)ALL_OBJECTS.

Last name and first name of all the


Last name and the first name of employees
only the employees in the department except those working in the department
number 3 and 5. 3and 5.
In operator. Like operators

Open the cursor. Close the cursor

SELECT last_name,salary
SELECT last_name,salary FROM employee;
FROM employee; WHERE id=3;

SELECT* SELECT deptno,dname,loc


INTO dept_rec INTO dept_rec
FROM dept FROM dept
WHERE dept no=10; WHERE dept no=10;

DECLARE
ANS)DECLARE CURSOR emp-cursor 1S
CURSOR emp-cursor 1S SELECT ename,dept no
SELECT ename,dept no FROM emp;
FROM emp; BEGIN
BEGIN FOR emp-rec IN emp-cursor LOOP
FOR emp-rec IN emp-cursor LOOP OPEN emp-cursor;
INSERT INTO temp-emp(name,dno) INSERT INTO temp-emp(name,dno)
VALUES (emp-rec.ename, VALUES (emp-rec.ename,
emp-re.deptno); emp_rec.deptno);
END LOOP END LOOP
END; END;

When any DML or select statement When a delete statement in a PL/SQL


is used in a PL/SQL block block deletes more than one row.

MY_VIEWS. ANS)USER_VIEWS.
0 ANS)1

ANS)all of the same data type all of different data type


Index-by tables Nested tables
varrays ANS)associative arrays

arbitrary numbers strings

arbitrary numbers strings

Index-by tables Nested tables

Index-by tables Nested tables


procedure Function

ANS)nested tables Associative array

BINARY_INTEGER SIGNTYPE

ANS)Index-by tables Nested tables


Index-by tables Nested tables

ANS)VALUE_ERROR SUBSCRIPT_BEYOND_COUNT.

VALUE_ERROR ANS)SUBSCRIPT_BEYOND_COUNT.
VALUE_ERROR SUBSCRIPT_BEYOND_COUNT.

Exists Trim
EXTEND TRIM
EXTEND EXISTS
ANS)Exists Extend

Extend(n) ANS)Exists(n)

ANS)IF projects.COUNT = 25 THEN IF COUNT = 25 THEN

Count Exists

Extends(n) ANS)Prior(n)
ANS)1 .. 2**31 1 ..  size_limit
1 .. 2**31 ANS)1 ..  size_limit

1 .. 2**31 1 ..  size_limit


ANS)We can check whether a collection is We can check whether two collections
null are the same
Distinct Group By

Nested tables Associative array

Count Limit

Count Limit

0 ANS)Null

Extends(n) Prior(n)

ANS)TRIM TRIM(n)

TRIM ANS)TRIM(n)

TRIM TRIM(n)

TRIM TRIM(n)
OPTION C OPTION D OPTION E

3 ANS)4
Set SESSION_OPEN_CURSORS
Set SESSION_CURSORS parameter parameter in the initialization
in initialization Parameter parameter

65535 0

ANS)2,3 1,2,5

The Job Queue Processes.

ANS)The Job Queue Processes.

Permanent Tablespace

ANS)1 & 2 2,3


The above statement has a syntax
error.

A,C All of the above

Method Object attribute

Declare (optinal) ANS)Declare (optional)


Begin (mandatory) …... sql Begin (mandatory)
stmts ……plsql stmts …... sql stmts ……plsql
Excecution (optional) End; stmts Exception (Optional)
(mandatory) End; (mandatory)
Users can customize the variable
types by using TYPE ... IS ... ANS)Variable Declaration is done in
statement. the Begin section of pl/sql code
structure
A function will returns a Scalar value
ANS)A Fucntion is is a standalone and must have a return statement in
executable statement in PL/SQL the Begin section

Anonymous blocks Cannot use


CURSORS ANS)Option 1 & Option 2

Packages collections

Compilation Error Runtime Error


DROP TRIGGER trigger_name ON DROP trigger_name ON
table_name; table_name;

ANS)INDEX Option 1 & Option 2

collections Recordset

same as for a table ANS)Option 1,3


The columns selected in the inline
view can be referenced in the parent
query ANS)All of the above

the select statement should not


contains a DISTINCT operator ANS)All of the above
You can write to the :NEW value but
not to the :OLD value.

ANS)Option 1,3

ANS)Option 1,2

You cannot specify UPDATE OF for


an INSTEAD OF trigger ANS)all of the above

Select timestamps,owner,obj_name Select timestamps,owner,obj_name


from dba_users; from all_objects

ANS)This occurs when a trigger trys


Occurs when a view is deleted to update a row it is currently using
DBMS_JOB UTL_FILE

SQLMSG ANS)SQLERRM

CREATE TABLE table_name AS A table cannot created through a


query; procdure

DROP TRIGGER trigger1,trigger2, ALTER TRIGGER trigger1,trigger2,


…,triggern ON table_name; …triggern ON table_name DISABLE;

Database columns cannot store the


values of cursor variable. ANS)all of the above
%NOTFOUND ANS)option,1,3
Execution part ANS)Option 1,3

%DATATYPE %ROWCOUNT
After commit statements all changes
will be stored permanently in the
database. ANS)all of these
A trigger constraint ANS)Option 1,2,3
UPDATE ANS)none of these

PER STATEMENT all of these

instead of triggers ANS)all of these

For triggers related to UPDATE only


OLD.column_name
NEW.column_name values only
available. ans)All of the above

Will get an error message saying "


table is locked for updation by
the table get locked another user"

FETCH .. INTO … ans)all of these

user_error ANS)all of these

Raise_application_error TOO_MANY_ROWS

ANS)Raise_application_error TOO_MANY_ROWS

IN-OUT ANS)ALL of these

Both procedure and functions are Both procedure and functions are
called a apart of the expression called as plsql statement

Cursor defined in the package


specification must have a RETURN
type. All of these
EXCECUTE
package_name.procuder(1); , if the
procedure have a IN parameter of
type NUMBER ANS)All of these
ANS)Function cannot be called from
RUN Package_name.function SQL *PLUS
TRANSACTION_TIMED_OUT ANS)NOT_VALID_NUMBER
NEXTVAL ANS)ROWCOUNT
The subquery used in WHERE
clause and it refers to any column in
the parent statement

ANS)The subquery used in WHERE


clause and it refers to any column in
the parent statement
Truncate will deletes the table
structure also. option 1,2

ANS)Indexes exist solely to Indexes rarely make a difference in


improve query speed SQL performance
Easy to install and use
Powerful GUI front-end

ANS)The quality of the SQL


optimization
The use of bitmap indexes

ANS)The same query can be


written in many ways, each with SQL creates excessive locks
vastly different execution plans within the Oracle database
GRANT UPDATE ON
GRANT UPDATE ON customer customer.title,customer.address TO
COLUMNS(title,addres) TO Adrew Adrew;
ANS)options 1,5,6 options 1,6,4

System privilege ANS)All of these


UPDATE & DELETE None of these

USER_DEPENDENCIES ANS)Option 2,3

DROP PACKAGE My_pack DROP package Body My_pack;

It is a system event trigger It is an application trigger


ANS)The statement will fail because The statement will fail because the
the NEW qualifier cannot be used in NEW qualifier cannot be used in an
a statement trigger AFTER trigger.

Internal LOB is a category of LOB ANS)all of these


Using ROWCOUNT in select
Using Sequence statement

TO_CHAR(sal,'WORDS') TO_DATE(TO_CHAR(sal,'JSP'),'j')

ANS)12 50

Get execution error Display all records in table emp.


NEXT_DAY ROUND

Only the rows with the correct data


Only the current row is affected. type are affected

Ensuring that a Foreign Key attribute ANS)The enforced synchronization of


cannot be NULL Primary Key and Foreign Key values

ANS)WHERE price IS NULL WHERE price != 0

A SELECT statement
COUNT MAX

Duration of the current SQL Server


Duration of the batch connection
ANS)EXIT CONTINUE

ANS)Views require the space used to


store a few records in various system Views do not store data and therefore
tables. use no space.

ANS)Dropping Foreign Key constraints


on the table Dropping indexes on a table

1000 bytes 2000bytes


CURSOR ANS)all of these
Yes, We can add a not null column
but it should be defaulted to some
value.

TABLE OF is dynamic cursor in


which the contents of cursor can be
changed dynamically at run time
depending upon our requirement.

TYPE rec RECORD is to be used


whenever query returns a entire row
of a table or view.
% ROWTYPE is to be used
whenever query returns columns of
different
table or views and variables.

UTL_FILE ans) All of the above


SQL language ANSI language
other PL/SQL blocks ans) All of the above
functions ans) none
used as an exception handler to create an output file
ans) CREATE FILE CREATE TABLE
ans) semi colon comma
depends on the OS defined at the database parameter
Maximum limit 10 only for packages
DECLARE ans) DATE
== .=
DBA creates the table and inserts
ans) one row
rows as needed
Used to limit at the maximum 2K size
Any data type can be stored
data
char data types Not a valid data type
to trim a string to a given length not a valid function
to trim a string to a given length not a valid function
ans) eliminate both leading and
to trim a string to a given length
trailing spaces
Integer format Oracle database format

ans) BINARY_INTEGER Same

UNHANDLED ans) VALUE_ERROR

PROCEDURE <name> AS
BEGIN
ans) B & C
<program code>
END
FUNCTION <name> AS RETURN FUNCTION <name> RETURN
<datatype> <datatype> AS
DECLARE DECLARE
BEGIN BEGIN
<program code> <program code>
END END
OUT variable of NUMBER type is
Declaure an input variable as INOUT
allowed
PACKAGE ans) B&C

SUBSTR A&D

ans) A & B BETWEEN

RANDOM RUNTIME

ans) to make the intended order of


is aesthetic
evaluation clear
NO ROWS FOUND RAISES syntax eror
NO ROWS FOUND RAISES syntax eror
when checking for an empty string is equal to comparing with ''
TO_CHAR ans) All of the above
TO_NUMBER TO_VARCHAR
ans) NULL RAISES syntax eror
NULL RAISES syntax eror
ans) X=1 OR X=2 OR X=3 X >= 1 AND X<=3
x='' x=' '
Removes the time portion Not a valid command
JANUARY 9-Jan
Logical Arithmetic
IF <condition> IF <condition>
<program_code> <program_code>
ELSE ELSEIF
<program_code> <program_code>
END; END;
FOR loop_index IN FOR loop_index IN
high_value..low_value high_value..low_value
LOOP LOOP
<program_code <program_code
END LOOP; END;

GOTO is not a valid statement GO TO Exit


WHILE <condition is FALSE> LOOP
LOOP WHILE <condition is TRUE>
<statements> <statements>
ENDLOOP; ENDLOOP;
While loop does not exists in Oracle
More than once
as in JAVA
ans) A & B Not needed
WHILE loop always ends gives syntax error
ans) A & B Not needed
logically grouped set of SQL
logically grouped set of stored events
statements that perform a specific
that perform a specific task
task
compilation is performed during run
time
using remove procedure command using del procedure command
a procedure that does not have a
ans) a procedure that calls itself
return statement
ans) A & B

invalid_cursor ans) All of the above


DELETE ans) All of the above
CREATE ans) All of the above
Data driven language
ans) TRUNCATE ROLLBACK
FIRST ans) All of the above
prior ans) All of the above
%recordtype %table of
variable with fixed number of
It is a variable of type table
columns
ROWID ans) All of the above
%NOTFOUND ans) All of the above
ans) A&B defined
%rowcount %open
%recordcount %total
A row in a table is deleted ans) All of the above
CREATE SESSION ans) A&C
functions Packages
ans) tells SQL & PLUS that we are used as a standard, semicolon can
done typing PLSQL code be used instead
UTL_FILE.WRITE UTL_FILE.FOPEN
ans) A & B

declare section ans) block

PLS_INTEGER ans) INT

4000 No limit

ans) Both None


1008 decimal digits ans) 38 decimal digits
the size and number of decimal
none
points
the size and number of decimal
none
points

ans) both none

VARCHAR2 TYPE

block size 2000

ans) CREATE OR REPLACE ans) CREATE OR REPLACE


TRIGGER <trigger_name> TRIGGER <trigger_name>
{BEFORE|AFTER} verb_list ON {BEFORE|AFTER} verb_list ON
<table_name> <table_name>
[FOR EACH ROW] FOR EACH ROW
DECLARE DECLARE
<variable list> <variable list>
BEGIN BEGIN
<program_code> <program_code>
END END

TRIGGER TABLE

LEFT RIGHT

Integer format ans) OR


validates packages ans) recompiles all packages
storate_error others
storate_error None

Legal because emp_rec takes the


type of emp_rec_type

Legal because it can reference any Legal because %type is new data
table and column type type available in higher versions

ans) Not legal because the INDEX


BY clause is missing

Former has declare Statement and


latter doesn’t. ans) A&C

truncate is efficient, triggers are not


ans) All of the above
fired

use "utl_file"

login_dened ans) None

Ref Cursor and Boolean ANS)A & D

A,D,E D,E
In Char type spaces will be padded
Both the cases the space will be after 'name' uptp max length 20.in
padded after 'name' upto max length Varchar spaces will padded before
20 'name' upto max length 20
After AS keyword we specify the
return datatype. After IS
Using AS will throw error while keyword we do the variable
compilation declaration

exist is faster than IN usage ANS)Option 1,3

INVALID_CURSOR ANS)Option1,2

3,4,1,2 2,1,4,3

No action is performed

Trigger tr2 is fired and a record is


inserted into table T

LANG LANGRA Simple


ANS)Declare V_sal emp.sal %
Declare V_sal emp.sal % TYPE; TYPE;
Begin SELECT Sal INTO V_sal Begin SELECT Sal INTO V_sal
FROM emp WHERE empno = and FROM emp WHERE empno = and
P_empno; P_empno;
IF (V_Sal&lt;1000) THEN IF (V_Sal&lt;1000) THEN
UPDATE emp Sal := Sal*1.1 UPDATE emp Set Sal := Sal*1.1
WHERE empno = and P_empno; WHERE empno = and P_empno;
END IF; END; END IF; END; Simple

ANS)Change the operator in the Add a second condition to the where


where condition condition Medium

This task cannot be accomplished


with
ANS)SQL % FOUND a SQL cursor attribute Simple

DBMS_OUTPUT.PUT_LINE
ANS)DBMS_OUTPUT.PUT_LINE (dept(dept_rec.dname); Simple
750 1000 Simple
DECLARE ANS)DECLARE
TYPE emp-table is TABLE of emp TYPE emp-table-type is TABLE of
%ROWTYPE emp%ROWTYPE
INDEX BY WHOLE NUMBER; INDEX BY BINARY INTEGER;
emp-table emp-table-type; emp-table emp-table-type; Simple

A cursor for each active set. ANS)A cursor that uses parameters. Simple

ANS)You do not explicitly open, fetch


You must explicitly close the cursor or close a cursor within a cursor FOR
prior to the end of program. loop. Simple
Programmers need to close all the
implicit Programmers can declare implicit
cursors before the end of the PL/SQL cursors by using the cursor type in
program. the declaration section Medium

1 NULL Simple
The data type in the select list are
inconsistent with the data types in
the into clause. ANS)Both A &B Simple
DECLARE
ANS)DECLARE v-hiredate DATE:=SYSDATE:
v-hiredate DATE:=SYSDATE: BEGIN
BEGIN INSERT INTO
INSERT INTO emp(empnp,ename,heridate,deptno)
emp(empnp,ename,hiredate) VALUES(empno_sequence.nextval,
VALUES(empno_sequence.nextval, 'and name',v_hitedate and deptno)
name, v_hiredate) Job=Clerk
END: END: Medium

6 ANS)8 Medium

An order by clause cannot contain a A group function cannot contain a


group function. single row function. Complex

Declarative Exception handling Complex


ANS)START myproc.sql EXECUTE myproc.sql Medium

ANS)Variable Y is declared in the Variable V_sal is declared in the


inner outer
block and referenced in the outer block and referenced in the inner
block. block. Complex

Procedure cal_max(n1 NUBER n2


NUMBER, p_max OUT NUMBER)
IS
BEGIN
ANS)Select ename,sal If n1>n2 then
into v_ename,v_sal p_max:=n1;
from emp Else
where p_max=n2;
empno=101; END.
It depends on the scale and precision The block will not execute because
of the variable. the variable was not initialized. Simple
Projection allows due to joined tables Projection allows due to add columns
together. to a table. Simple

ANS)dept_table(15).loc := 'Atlanta'; dept_table_type(15).loc := 'Atlanta';

UPDATE emp
ANS)UPDATE emp SET values job = 'Administrative
SET job = 'Administrative Clerk' Clerk'
WHERE UPPER (job) = 'CLERK'; WHERE UPPER (job) = 'Clerk'; Simple

ANS)The cursor does not need to be


No FETCH statements were issued. explicitly closed. Simple

CALC_PLAYER('RUTH'); START CALC_PLAYER_AVG(31); Simple


You can view whether an object is
valid or invalid in the
USER_OBJECTS data dictionary
view ANS)ALL the above Medium

add_dept(, 'New York'); ANS)Exec add_dept;


ANS)You can achieve information
A package is loaded into memory hiding by making package constructs
each time it is invoked. private Medium

Trigger ANS)Both A &B Simple

It does not persist across It persists from user to user when the
transaction within a session. package is invoked. Medium

CREATE OR REPLACE TRIGGER CREATE OR REPLACE TRIGGER


check_sal check_sal
BEFORE UPDATE OF sal ON emp AFTER UPDATE OR sal ON emp
WHEN (new.sal < old.sal OR WHEN (new.sal < old.sal OR
new.sal > old.sal * 1.1) -new.sal > old.sal * 1.1)
BEGIN BEGIN
RAISE_APPLICATION_ERROR ( - RAISE_APPLICATION_ERROR ( -
20508, 'Do not decrease 20508, 'Do not decrease
salary not increase by more than salary not increase by more than
10%'); 10%');
END; END;
Complex
You can call the You can call the
BONUS.CALC_SALARY packaged BONUS.CALC_SALARY packaged
function form a function from an UPDATE
DELETE command against the command against the EMPLOYEES
EMPLOYEES table table. Complex

For faster removal and re-creation,


do not use a drop procedure
statement. Instead, recompile the
Use a drop procedure statement to procedure using the alter procedure
drop a procedure that is part of a statement with the REUSE
package. SETTINGS clause
Then recompile the package body. Medium

FOR EACH ROW trigger on the Statement-level trigger on the


AUDIT_TABLE table. AUDIT_TABLE table Medium
ANS). If errors occur during the
If errors occur during the compilation compilation of a trigger you can go
of a trigger you can use the SHOW into SQL *Plus and query the
ERRORS command within iSQL USER_ERRORS data dictionary
*Plus to see the compilation errors. view to see compilation errors Medium
ANS)USER_DEPENDENCIES DBA_DEPENDENT_OBJECTS

ANS)You need to create a SQL


You need to create a SQL *Plus *Plus environment variable X and
environment variable X and issue the issue the command EXECUTE :X :=
command :X := CALCTAX(1000);. CALCTAX(1000); Medium

ANS)The SQL statement is run and


An area of memory is established the number of rows processed is
to process the SQL statement. returned. Medium

Trigger event Trigger timing Simple

The SQL statement executes


The statement fails because the successfully, because UPDATE and
functions DELETE statements are ignoring in
does not contain code to end the stored functions called from SQL
transaction. expressions Complex

ANS)USER_OBJECTS USER_PLSQL_UNITS Medium


System event trigger ANS)This is an invalid trigger Complex

ANS)The value of
The value of DISCOUNT_RATE is DISCOUNT_RATE is set to 0.10
set to 1.00 each time the procedure when the package is invoked for the
DISPLAY_PRICE is invoked. first time in a session Complex
A value equal to the number of rows
NONE in the EMP table. Complex

PL/SQL table of scalars. ANS)PL/SQL table of records. Simple

The package specification is optional, Both the specification and body are
but the package body is required. required components of a package Medium

ANS)SHOW ERRORS SHOW ALL_ERRORS Simple


A specific user or any user logs on or oANS)ALL THE ABOVE Simple
RUN UPD_BAT_STAT(V_ID); START UPD_BAT_STAT(V_ID); Simple

You use a system event trigger to fire You use INSTEAD OF trigger to fire
when an UPDATE statement occurs. when a SELECT statement occurs. Simple

A s0tandalone procedure on the A block of code in the body of the


client machine. program unit ORDERTOTAL Simple

ANS)OUT IN Simple

ON SHUTDOWN ANS)BEFORE Simple

USER_REFERENCES USER_SOURCE Medium


ANS)A stored procedure Another database trigger Medium
ALTER TRIGGER business_hour
REMOVE TRIGGER business_hour; REMOVE; Simple

Use the
DBMS_LOB.MIGRATE ANS)Use the ALTER TABLE
procedure command. Medium

ANS)EXECUTE
INSERT_TEAM(3,
'AUSTIN','LONGHORNS'); BOTH B AND C Medium
The executable section of a stored
procedure contains statements that
assigns values, control execution,and
return values to the calling A stored procedure is typically
environment. written in SQL. Simple
EXECUTE add_dept
EXECUTE add_dept('2500', p_loc =>2(p_name=>'Education', 2500) Medium

Declaring variables with the %TYPE Declaring records by using the


attribute. %ROWTYPE attribute Simple
The statement level or for
The package associated with the triggeeach row association to the trigger. Simple
ANS)UPDATE_SAL DELETE_EMP Medium

Use the DBMS_LOB.FILEEXISTS ANS)Use the


function to find the location of a DBMS_LOB.FILECLOSE procedure
BFILE. to close the file being accessed. Complex
g_comm has a value of 20 at 9:06am g_comm has a value of 15 at 9:03
for both Jones and Smith. am for both Jones and Smith. Medium
DELETE gen_email_name; NONE Simple

EXECUTE UPD_BAT_STAT(V_AB=>10,
ANS)BOTH AND C Simple

The trigger invoked the procedure ANS)The trigger invokes the


audit_action each time a user logs on procedure audit_action each time
to his/her schema and adds the a user logs on to the database and
username to the audit table adds the username to the audit table. Medium
ANS)OPEN emp_cursor(10, 'analyst'); OPEN emp_cursor (p_deptno,p_job);
Statement level DML trigger Row level system trigger Medium

ANS)Stored functions can increase


the
efficiency of queries by performing
functions
in the query rather than in the Stored functions cannot manipulate
application new types of data, such as longitude
and latitude Medium

Take out the COUNT function


because Change the trigger type to a
it is not allowed in a trigger. BEFORE DELETE. Medium
ANS)A stored procedure must have
at least A stored procedure uses the
one executable statement in the DECLARE keyword in the procedure
procedure body. body to declare formal parameters. Simple

Cluster Package Medium


CREATE OR REPLACE FUNCTION CREATE OR REPLACE
tax_amt PROCEDURE tax_amt
(p_id NUMBER) (p_id NUMBER, p_amount OUT
RETURN NUMBER(10,2) NUMBER(10, 2))
Simple

INSTEAD OF trigger Application trigger Complex

ANS)The trigger fails because a The trigger fails because you cannot
SELECT use the minimum and
statement on the table being updated maximum functions in a BEFORE
is not allowed. UPDATE trigger Medium

This statement creates a stored


function named get_sal with a status
of invalid. ANS)This statement fails. Medium
None of these commands; you
cannot disable
ANS)ALTER TABLE employees multiple triggers on a table in one
DISABLE ALL TRIGGERS; command Medium

A file stored outside of the database,


with an internal pointer to it from a
A column that is a primary key. database column. Medium
ANS)SELECT salary,
DELETE FROM calc_sal(salary)
employees(calc_sal(salary)) FROM employees
WHERE calc_sal(salary) > 1000; WHERE department_id = 60;
Medium

ORACLE FORM trigger Before Medium


If you remove the package If you remove the package body,
specification, then the package specification is
then the package body is removed removed. Simple
ANS)A conditional predicate allows A conditional predicate allows you to
you to combine several DBM specify a SHUTDOWN
triggering events into one in the or STARTUP condition in the trigger
trigger body. body. Medium

GRANT SELECT, EXECUTE ON


TEAM,
GRANT EXECUTE ON TEAM TO PUBUPD_TEAM_STAT TO PUBLIC; Medium
DECLARATIVE,EXECUTABLE and
ANS)EXECUTABLE and HEADER EXCEPTION HANDLING Simple

Declarative Exception handling. Simple


A variable is in an inner block may
have the same name as a variable in
A variable defined in the inner block an outer block only if the data
is visible in the outer blocks. types are different. Medium
By inserting the statement ANS)By inserting the statement
DBMS_OUTPUT.DEBUG_VAR (i , DBMS_OUTPUT.PUT_LINE (i | | ``| |
v_date); TO_CHAR( v_date));
Between lines 8-9 Between lines 8-9 Medium

This code displays salaries


ANS)IF (v_sal.GT.10000) THEN if larger than 10000. Medium

DBA_SEGMENTS. DBA_TABLES. Medium

ANS)Last name and first name of all Last name and first name of only the
the employees employees whose salary falls in the
with the same salary as employee in range of salary from
the department 3 and 5. department 3 or 5. Medium
ANS)Equal operators. Between x and y operator. Simple
ANS)Test for the rows using the
Initialize the loop. cursor attribute. Simple

ANS)SELECT last_name,salary SELECT l last_name,salary


INTO v_last_name,v_salary FROM employee;
FROM employee INTO v_last_name,v_salary
WHERE id=3; WHERE id=3; Simple

SELECT*
INTO
dept_rec.dno,dept_rec.name,dept_re
ANS)You can't retrieve the entire row c.
using the DEPT_REC variable FROM dept
declared in the code. WHERE dept no=10; Medium

DECLARE
DECLARE CURSOR emp-cursor 1S
CURSOR emp-cursor 1S SELECT ename,dept no
SELECT ename,dept no FROM emp;
FROM emp; emp-rec emp-cursor%ROWTYPE;
BEGIN BEGIN
FOR emp-rec IN emp-cursor LOOP FETCH emp-cursor
OPEN emp-cursor; INTO emp-rec;
INSERT INTO temp-emp(name,dno) FOR emp-recIN emp-cursor LOOP
VALUES (emp-rec.ename, INSERT INTO temp-emp(name,dno)
emp-rec.deptno); VALUES (emp-rec.ename,
END LOOP emp-rec.deptno);
CLOSE emp-cursor; END LOOP
END; END; Simple
When an update statement in a
ANS)When a select statement in a PL/SQL block has to modify more
PL/SQL block is more than one row. than one row. Simple

SYSTEM_VIEWS. USER_TAB_VIEWS. Simple


2 3 Medium
some of same data type and some of
different data type none Medium
Varrays ANS)all the above Simple
Nested tables none Medium

sequential numbers ANS)both a and b Medium

ANS)sequential numbers both a and b Medium

Varrays ANS)both b and c Medium

ANS)Varrays both b and c Medium


Package ANS)All the above Medium

Both a and b none

STRING ANS)all the above Medium

Varrays None Medium


Varrays ANS)Both b and c Medium

SUBSCRIPT_NULL COLLECTION_IS_NULL Medium

SUBSCRIPT_NULL COLLECTION_IS_NULL Medium


SUBSCRIPT_NULL ANS)COLLECTION_IS_NULL Medium

Limit ANS)Both and b Medium


DELETE ANS)All the above Medium
PRIOR ANS)BOTH B AND C Medium
Prior Count Medium

Next(n) Count Simple

IF COUNT(projects) = 25 THEN IF COUNT(*) = 25 THEN Medium

ANS)Limit Extends Medium

Next(n) First(n) Medium


-2**31 .. 2**31 none Medium
-2**31 .. 2**31 none Medium

ANS)-2**31 .. 2**31 none Medium


greater than operator between two less than operator between two
collections collections Medium
Order By ANS)All the above Medium

ANS)Varrays None Medium

Last ANS)First Simple

ANS)Last First Simple

1 None Medium

ANS)Next(n) Last(n) Medium

DELETE DELETE(n) Medium

DELETE DELETE(n) Medium

ANS)DELETE DELETE(n) Medium

DELETE ANS)DELETE(n) Medium


DIFFICULTY LEVEL

Medium

Difficult

Difficult

Medium

Medium

Medium

Medium

Medium

Medium
Medium

Medium

Medium

Medium

Medium
Medium

Medium

Medium

Medium

Medium

Medium

Medium

Medium

Medium

Medium

Medium

Medium
Medium

Medium

Medium

Medium

Medium

Medium

Medium

Medium

Medium

Medium

Medium

Medium

Medium

Medium

Medium

Medium
Medium

Medium
Difficult

Difficult
Difficult

Difficult

Medium

Difficult

Difficult

Difficult

Simple

Difficult

Difficult

Difficult

Medium

Medium

Difficult
Difficult

Difficult

Difficult
Difficult

Difficult

Difficult

Difficult

Difficult

Difficult

Difficult

Difficult

Difficult
Difficult

Difficult

Complex

Difficult

Medium

Difficult
Difficult

Difficult

Difficult

Difficult

Difficult

Medium

Medium

Medium

Difficult

Medium

Medium

Medium

Medium
Medium

Difficult

Difficult

Difficult

Difficult

Difficult

Difficult

Difficult

Difficult

Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium

Medium

Medium

Medium
Medium
Medium

Medium

Medium

Medium

Medium

Medium

Medium

Medium

Medium

Medium

Medium

Medium

Medium

Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium

Medium

Medium

Medium
Medium
Medium

Medium

Medium

Medium
Medium
Medium

Medium

Medium

Medium

Medium

Medium

Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium

Medium

Medium
Medium
Medium
Medium
Medium
Medium
Difficult
Difficult

Difficult

Difficult
Difficult

Difficult

Difficult

Difficult

Difficult

Difficult
Difficult

Difficult

Difficult

Difficult

Difficult

Difficult

Difficult

Difficult

Difficult

Difficult
Difficult
Difficult
Difficult

Difficult

Difficult

Difficult

Difficult

Difficult

Difficult

Complex

Complex

Complex

Medium
Medium

Medium

Medium

Medium

Medium

difficult

difficult

Difficult
QUESTION # QUESTIONS

10

11

12

13

14

15
Option A Option B Option C Option D Option E
Solution
QUESTION # QUESTIONS Option A Option B Option C Option D Option E Solution
QUESTION
QUESTIONS
# Option A Option B Option C Option D Option E Solution
QUESTION
QUESTIONS
# Option A Option B Option C Option D Option E Solution

You might also like