How To Control How Many Cursors Are Open in An Session: Q UE ST IO N #

You might also like

Download as xls, pdf, or txt
Download as xls, pdf, or txt
You are on page 1of 26

Q

UE
ST
IO
N
# QUESTIONS OPTION A OPTION B OPTION C OPTION D
How many types of Scrollable Cursors are there in
1 PL/SQL 1 2 3 ANS)4

There is no absolute
limit to the total Set
number of cursors SESSION_CURS
ANS)Set OPEN_CURSORS one session can ORS parameter in Set SESSION_OPEN_CURSORS
How to control how many cursors are open in an parameter in initialization have open at one initialization parameter in the initialization
2 session parameters time Parameter parameter
What is the default Value for OPEN_CURSORS
3 parameter for a session ANS)50 25 65535 0
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,4 2,3,4 ANS)2,3 1,2,5
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 The Job Queue
5 process cleans up after it? ANS)PMON SMON Processes.

What background process refreshes materialized


views? ANS)The Job
6 PMON SMON Queue Processes.
Name a tablespace automatically created when you
create a database. Temporary Permanent
7 ANS)SYSTEM tablespace tablespace Tablespace
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; 1 2 ANS)1 & 2 2,3

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
ANS) Scott does not
database? You do not have the UPDATE have the UPDATE The above
object privilege on the object privilege on statement has a
9 EMP_SAL table. the EMP_SAL table syntax error.
You cannot grant privileges on remote objects to
other users.
10 ANS)TRUE 0
Which of the following operations cannot be
performed using database links to a remote
11 database.
A) Grant privileges on remote objects ANS)A & D A,B,D A,C All of the above
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. ANS)Object type Attribute Method Object attribute
Declare
(optinal)
Begin
Declare(mandatory) (mandatory)
Begin …... sql stmts
Declare(mandatory) (mandatory) …... ……plsql stmts
Begin (mandatory) sql stmts ANS)Declare (optional)
…... sql stmts ……plsql stmts Excecution Begin (mandatory)
……plsql stmts Exception(optional) (optional) …... sql stmts ……plsql
Exception(mandatory) End; End; stmts Exception (Optional)
13 What is the Basic PL/SQL Code Structure? End; (mandatory) (mandatory) (mandatory) End; (mandatory)
Users can
Only TRUE or customize the
FALSE can be variable types by
assigned to using TYPE ... ANS)Variable Declaration is done in
Variable must be declared BOOLEAN type of IS ... statement. the Begin section of pl/sql code
14 Which statement is wrong? before the usage variable structure
ANS)A Fucntion is
is a standalone
Function can be executable A function will returns a Scalar value
A functions must returns a called as a part of a statement in and must have a return statement in
15 Which Statement is Wrong about Functions in plsql? value. expression PL/SQL the Begin section
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. ANS)TRUE 0

By using block
labels, you can give
a name to your block
Anonymous blocks don't have for the duration of its Anonymous
names under which they can be execution, using blocks Cannot use
17 Which statement is true regarding anonymous block stored in the database PL/SQL labels . CURSORS ANS)Option 1 & Option 2
Which is the PL/SQL procedure that are associated
with tables and are called whenever certain
18 modifications(events) occurs. ANS)Triggers Functions Packages collections
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 0 ANS)TRUE
BEFORE UPDATING
SOME PERSON(S)

BEFORE
The PERSON table contains 5 records.An update UPDATING SOME
trigger is created on the table as below PERSON(S)
CREATE OR REPLACE TRIGGER
PERSON_TRIGGER BEFORE UPDATE BEFORE UPDATING
SOME PERSON(S)
ON PERSON
BEGIN BEFORE
DBMS_OUTPUT.PUT_LINE('BEFORE UPDATING UPDATING SOME
PERSON(S)'); PERSON(S)
END;
BEFORE UPDATING
What will be the result of below update statement on ANS)BEFORE UPDATING SOME PERSON(S)
the table? SOME PERSON(S)
20 Update PERSON SET DOB = SYSDATE; 5 Rows Updated 5 Rows Updated Compilation Error Runtime Error
ANS)DROP DROP TRIGGER
TRIGGER trigger_name ON DROP trigger_name ON
21 What is the syntax to drop a trigger? DROP trigger_name; trigger_name; table_name; table_name;
is a database structure that provides quick lookup of
22 data in a column or columns of a table. PRIMARY KEYS UNIQUE KEY ANS)INDEX Option 1 & Option 2
A ---- is a specific representation of data from one or
23 more tables Synonym ANS)Views collections Recordset
Maximum number of columns that can be defined in same as for a
24 a view 1000 512 table ANS)Option 1,3

The view will become invalid whenever the base


26 table is altered ANS)TRUE 0
Inline view is The columns
enclosed in selected in the
Inline view is a subquery that parenthesis and may inline view can be
appears in the from clause of be given an alias referenced in the
27 what is true about inline views the select statement name. parent query ANS)All of the above

if an inherently
updatable view
contains
pseudocolumns or
expressions, then
you cannot update
base table rows with
an UPDATE the select
statement that refers statement should
Each column in the view must to any of these not contains a
For a view to be inherently updatable,which of the map to a column of a single pseudocolumns or DISTINCT
28 following conditions must be met? table expressions operator ANS)All of the above

You can write to


the :NEW value
but not to the
You cannot specify a BEFORE You cannot perform :OLD value.
trigger on a view or an object DML with BEFORE
29 What are the restrictions on BEFORE trigger view trigger ANS)Option 1,3

You cannot specify an AFTER You cannot write


trigger on a view or an object either the :OLD or
30 What are the restrictions on AFTER trigger view the :NEW value. ANS)Option 1,2

You can read both


the :OLD and the You cannot
:NEW value, but you specify UPDATE
cannot write either OF for an
INSTEAD OF triggers are valid the :OLD or the INSTEAD OF
31 What are the restrictions on INSTEAD OF triggers only for views. :NEW value. trigger ANS)all of the above

Select Select
ANS)Select timestamps,owner,o timestamps,owne
timestamps,owner,obj_name bj_name from r,obj_name from Select timestamps,owner,obj_name
32 How to know the last executed procedure? from dba_audit_trial; dba_objects; dba_users; from all_objects

Occurs whena trigger is This occurs when a Occurs when a ANS)This occurs when a trigger trys
33 What is mutating table error? disabled table is updated view is deleted to update a row it is currently using
34 Which is not a oracle package? ANS)DBMS_OUT DBMS_PIPE DBMS_JOB UTL_FILE
The ----- returns the actual error message for the
35 last error encountered SQLERROR SQLCODE SQLMSG ANS)SQLERRM
36 A table can be created through a procedure 1 0
ANS)EXECUTE
IMMEDIATE
'CREATE TABLE CREATE TABLE
EXECUTE SQL 'CREATE table_name AS table_name AS A table cannot created through a
37 How we can create a table through procedure ? TABLE table_name AS query'; query'; query; procdure
ANS)Yes, Instead of a cursor No, We cannot use
we can use subquery in the subquery in FOR
38 Can we use a subquery in FOR clause? FOR clause clause
ANS)ALTER TABLE DROP TRIGGER
table_name trigger1,trigger2,
ALTER TABLE table_name DISABLE ALL …,triggern ON ALTER TRIGGER trigger1,trigger2,
39 How to disable multiple triggers on a table at a time? DISABLE; TRIGGERS; table_name; …triggern ON table_name DISABLE;
Cursor variable cannot be declared in a package
40 specification ANS)TRUE 0

Cannot use
comparision
operators to test Database columns
cursor variable for cannot store the
Cannot assign NULL to curosr equality,inequality or values of cursor
41 What are the restrictions on Cursor variable? variable nullity variable. ANS)all of the above
42 What are the cursor attribute used in PL/SQl? %ROWCOUNT %CURSOROPEN %NOTFOUND ANS)option,1,3
43 What are the components of PL/SQL blocks? Declarative Part Definition Part Execution part ANS)Option 1,3
_______provides the record type that represents a
entire row of a table or view or columns selected in
44 the cursor ANS)%ROWTYPE %TYPE %DATATYPE %ROWCOUNT

The cursor having After commit


query as SELECT.... statements all
The cursor having query as does not get closed changes will be
SELECT .... FOR UPDATE even after stored
What will happen after the execution of COMMIT gets closed after COMMIT/ROLLBAC permanently in the
45 statement? COMMIT/ROLLBACK K. database. ANS)all of these
A trigger
46 Which all are the part of database trigger? Triggering event Triggering action constraint ANS)Option 1,2,3
47 Which is not a triggering event INSERT DELETE UPDATE ANS)none of these
Triggering Constraint is specified using _______ PER
48 clause ANS)WHEN FOR EACH ROW STATEMENT all of these
Statement level
49 Which all are the different types of database trigger? Row-level triggers triggers instead of triggers ANS)all of these
Is it possible to use transaction control statements in
50 database triggers? ANS)NO YES

For triggers
For triggers related related to
to INSERT only UPDATE only
NEW.column_name OLD.column_nam
values only available. e
For triggers related to DELETE NEW.column_na
only OLD.column_name values me values only
51 Which of the follwing statements are true ? only available. available. ans)All of the above
What happens if a procedure that updates a column
of table X is called in a database trigger of the same Will get an error message saying "
table ? Trigger is executed the table get table is locked for updation by
52 ANS)Mutation of tables occurs successfully locked another user"
Which are the plsql statement used in Cursor
processing? FETCH .. INTO
53 CURSOR Cursor_name OPEN Cursor name … ans)all of these
Name the tables where characteristics of Package,
54 procedure and functions are stored ? User_objects user_source user_error ANS)all of these
The _____________
tells the compiler to assosiate
an exception with an oracle error. ANS)PRAGMA_EXCEPTION_I Raise_application
55 NIT EXCEPTION _error TOO_MANY_ROWS
is a
procedure of package DBMS which
allows to issue user_defined error ANS)Raise_applic
56 message PRAGMA_EXCEPTION_INIT EXCEPTION ation_error TOO_MANY_ROWS
What are the modes of parameters that can be
passed to a procedure ?
57 IN OUT IN-OUT ANS)ALL of these
ANS)Procedure is
called as plsql Both procedure
Procudute is called as a part of statement.Function is and functions are
What is the difference in calling functions and an expression . Functions are called as a part of an called a apart of Both procedure and functions are
58 procedure in a PL/SQL block called as a plsql statement expression the expression called as plsql statement
Cursor defined in
the package
What is difference between a Cursor declared in a Cursor defined in a specification must
procedure and Cursor declared in a package Cursor defined in package procedure is local to have a RETURN
59 specification specification is global that procedure type. All of these

Variable a NUMBER;

EXCECUTE EXCECUTE
package_name.proc package_name.pr
EXCECUTE uder(:a); , if the ocuder(1); , if the
package_name.procedure,if procedure have a out procedure have a
procedure doesnot have any or inout parameter of IN parameter of
60 How to call packaged procedure from SQL *PLUS in,in-out p[arameters. type NUMBER type NUMBER ANS)All of these
Return RUN
Execute package_name.functi Package_name.fu ANS)Function cannot be called from
61 How to call packaged function from SQL *PLUS package_name.function; on nction SQL *PLUS
DUP_VAL_ON_INDE TRANSACTION_
62 Which one is not a named system exception? NO_DATA_FOUND X TIMED_OUT ANS)NOT_VALID_NUMBER
63 Which is not a pseudocolumns? ROWNUM ROWID NEXTVAL ANS)ROWCOUNT

The subquery
used in WHERE
It's a subquery in the FROM clause and it
clause with an alias that can be ANS)The subquery refers to any
used as a view within the SQL used in WHERE column in the
64 What is a nested subquery? statement clause parent statement

ANS)The
subquery used in
It's a subquery in the FROM WHERE clause
clause with an alias that can be and it refers to
used as a view within the SQL The subquery used any column in the
65 What is a correlated subquery? statement in WHERE clause parent statement
Truncate will
Why use Truncate over Delete while deleting all When truncate is used, deletes the table
66 rows ? Triggers are not fired It deallocates space structure also. option 1,2

Indexes are used ANS)Indexes


What best describes the relationship between to make table exist solely to
indexes and SQL performance? Indexes are only used in storage more improve query Indexes rarely make a difference in
67 special cases efficient speed SQL performance
Which of the following is an important feature of ANS)Independence of table Powerful GUI Easy to install and use
68 relational databases and SQL? relationships High speed of SQL front-end

Which of the following is an important consideration The number of CPUs on the The degree of ANS)The quality of the SQL
when tuning an SQL statement? server parallelism on the The use of optimization
69 tables bitmap indexes

ANS)The same
SQL syntax is too query can be
difficult for non- written in many
computer ways, each with
SQL cannot support object- professionals to vastly different SQL creates excessive locks
70 Which is a major problem with SQL? orientation use execution plans within the Oracle database
ANS)GRANT
UPDATE GRANT UPDATE
GRANT UPDATE ON (title,address) ON ON customer GRANT UPDATE ON
CUSTOMER (title,address) TO CUSTOMER TO COLUMNS(title,ad customer.title,customer.address TO
71 Which statement is correct? ANDREW; ANDREW; dres) TO Adrew Adrew;

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. ANS)options
72 6) A roel is created using create role statement. Option 1,2,3 Option 2,5,6 1,5,6 options 1,6,4
A user can be assigned several roles and a single
73 role can be granted to several users ANS)TRUE 0
74 What are the different types of privileges Object privilege Role privilege System privilege ANS)All of these
UPDATE &
75 MERGE command is a combination of? ANS)INSERT & UPDATE INSERT & DELETE DELETE None of these

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 ALL_DEPENDENCIE USER_DEPENDE
76 function USER_DB_LINKS S NCIES ANS)Option 2,3

The database contains a package named


my_pack.you wast to delete the package
specification from the database while retaining the DROP
package body.which of the following statement will ANS)You cannot accomplish package_specificatio DROP PACKAGE
77 accomplish this? this n My_pack; My_pack DROP package Body My_pack;

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; It is a system
78 Which statement is true about aud_trigger? ANS)It’s a invalid trigger It’s a DDL Trigger event trigger It is an application trigger
CREATE OR REPLACE TRIGGER audit_trigger
AFTER INSERT ON Employee
BEGIN
INSERT INTO employee_audit ANS)The
VALUES(emp_id,:NEW.last_name,:NEW.first_name The statement will statement will fail
fail because the because the NEW
); NEW qualifier cannot qualifier cannot be The statement will fail because the
END; The trigger wil created be prefixed with used in a NEW qualifier cannot be used in an
79 What will happen when this statement is executed? successfully colon. statement trigger AFTER trigger.
LOB represnts a
datatype used to
store
Which of the following statement about LOB are LOB can be stored inside or large,unstructured Internal LOB is a
80 true? outside a datasase data category of LOB ANS)all of these
ANS)using
Using ROWID in the select ROWNUM in the Using ROWCOUNT in select
81 How to display row number with the records statement select statement Using Sequence statement
How to display a number value in words where ANS)TO_CHAR TO_CHAR(sal,'W
82 vriable sal is of type number? ( TO_DATE(sal,'j') , 'JSP' ) TO_CHAR(sal) ORDS') TO_DATE(TO_CHAR(sal,'JSP'),'j')
What is maximum no of triggers applied to a single
83 table 100 10 ANS)12 50
What does the below statement does?
select * from emp where (rowid,1) in (select rowid,
mod(rownum,2) from emp); ANS)Dispalys odd number of Get execution
84 records Give runtime error error Display all records in table emp.
ANS)MONTHS_BET
85 Which date function returns a number value ADD_MONTHS WEEN NEXT_DAY ROUND

The query returns an


Omitting the WHERE clause of an UPDATE or error because the
DELETE statement has what effect? ANS)All rows in the specified WHERE clause is Only the current Only the rows with the correct data
86 table are affected required. row is affected. type are affected

Ensuring that a
The enforced Foreign Key
The enforced uniqueness of a uniqueness of a attribute cannot ANS)The enforced synchronization of
87 Referential integrity refers to what? row in a table column in a table be NULL Primary Key and Foreign Key values

What statement could you use in the WHERE clause


to select all the rows in a table where no price is ANS)WHERE
88 defined WHERE price IS NOT NULL WHERE price IS < 0 price IS NULL WHERE price != 0

When using an INSERT statement, data to be


inserted may come from which of the following?
A SELECT
89 The VALUES clause A stored procedure statement

90 Which of the following is not a aggregate functions? SUM ANS)ABS COUNT MAX
What is the lifetime of a user-defined variable? Duration of the Duration of the Duration of the current SQL Server
91 ANS)Duration of the script statement block batch connection
Which of the following commands can be used to
interrupt processing of a While loop?
92 BREAK HALT ANS)EXIT CONTINUE

Views require as ANS)Views require


much space as would the space used to
Views require as much space as a table that store a few
all the tables they are created presented the same records in various Views do not store data and therefore
93 What are the space requirements for views? from. data. system tables. use no space.

ANS)Dropping
Deleting all of the Foreign Key
Which of the following best describes a situation in Random rows in the table have records of a specific constraints on the
94 which the statistics for a table would be misleading been deleted gender table Dropping indexes on a table

ANS)the maximum output is


determined by the size you
specified in
what is the maximum size of the message that we can dbms_output.enable(<size>)
95 give in dbms_output.putline(); . 255bytes 1000 bytes 2000bytes
96 How can we retrive multiple rows in PLSQL BULK COLLLECT REF CURSOR CURSOR ANS)all of these

Yes, We can add


ANS)Yes,we can add a not null a not null column
constraint to a column, but but it should be
already existing row should defaulted to some
Can you add not null column to a table already have a data for that column. value.
97 containing data ? No
ANS)YES, function
can return more than
A function can return more than one value. Is this one value using ref
98 statement true? NO cursor

TABLE OF is
dynamic cursor in
which the
contents of cursor
can be changed
dynamically at run
time depending
A variable declared upon our
ANS)Table of is use to define a based on TABLE OF requirement.
Which statement is true about 'TABLE OF' in collection type. data type is called
99 PL/SQL cursor variable.
ANS)% ROWTYPE TYPE rec
is to be used RECORD is to be
whenever query used whenever
returns a entire row query returns a
of a table or view. entire row of a
table or view.
TYPE rec
RECORD is to be %
used whenever ROWTYPE is to
query returns be used whenever
columns of different query returns
table or views and columns of
variables. different
What is difference between %ROWTYPE and TYPE table or views and
100 RECORD? No difference variables.

101 The following are Oracle supplied packages DBMS_OUTPUT DBMS_SQL UTL_FILE ans) All of the above
unstructed
102 PLSQL is referred to as a ans) block structured language SQL language ANSI language
langugage
other PL/SQL
103 PLSQL block can contain the following variable declarations program code ans) All of the above
blocks
104 A PLSQL block cannot contain the below other PL/SQL blocks error handlers functions ans) none
ans) to display the used as an
105 What is the use of DBMS_OUTPUT To handle errors to create an output file
output exception handler
ans) CREATE
106 Which one of these is not a valid privelege CREATE TYPE CREATE TRIGGER CREATE TABLE
FILE
107 Every PLSQL statement is followed by a delimeter quote ans) semi colon comma
depends on the
108 PL/SQL commands are case sesitive Yes ans) No defined at the database parameter
OS
109 PLSQL blocks can be nested ans) Yes No Maximum limit 10 only for packages

110 Which of these is not a PLSQL keyword BEGIN END DECLARE ans) DATE
111 Which symbol is used in assignment statement = ans) := == .=
DBA creates the table and inserts
112 How many rows the table DUAL has No rows Multiple ans) one row
rows as needed
ans) Variable length character Character string with Any data type can Used to limit at the maximum 2K size
113 VARCHAR2 data type is used to store
strings 2 bytes size be stored data
ans) Fixed length
114 CHAR data type is used to store Character data types char data types Not a valid data type
character strings
ans) eliminate trailing to trim a string to a
115 RTRIM function is used to elimiate leading spaces not a valid function
spaces given length
eliminate trailing to trim a string to a
116 LTRIM function is used to ans) elimiate leading spaces not a valid function
spaces given length
eliminate trailing to trim a string to a ans) eliminate both leading and
117 TRIM function is used to elimiate leading spaces
spaces given length trailing spaces
118 BINARY_INTEGER variables are stored using same as number data type ans) binary format Integer format Oracle database format
ans)
Among NUMBER and BINARY_INTEGER data
119 NUMBER BINARY_INTEGER BINARY_INTEGE Same
types which one takes less space R

120
Which exception is raised when we assign the ILLEGAL
WRONG_DATA_TY
UNHANDLED ans) VALUE_ERROR
wrong type of value to a variable PE
PROCEDURE PROCEDURE
PROCEDURE <name>
<name> IS <name> AS
BEGIN
121 The syntax for declaring a procedure BEGIN BEGIN ans) B & C
<program code>
<program code> <program code>
END
END END

FUNCTION
FUNCTION <name> RETURN ans) FUNCTION <name> AS FUNCTION <name> RETURN
<datatype> <name> RETURN RETURN <datatype> AS
DECLARE <datatype> IS <datatype> DECLARE
122 The syntax for declaring a function
BEGIN BEGIN DECLARE BEGIN
<program code> <program code> BEGIN <program code>
END END <program code> END
END

Declaure an input OUT variable of NUMBER type is


123 Functional can have an OUT variable ans) No Yes
variable as INOUT allowed

124 Which of the does not return a value FUNCTION PROCEDURE PACKAGE ans) B&C

125
What can you do to ignore the time portion of a ans) TRUNC TRIM SUBSTR A&D
DATE variable
126
Which functions are useful when comparing case- LOWER UPPER ans) A & B BETWEEN
insenitive string comparisons
127
Operators of the same precedence level are RIGHT to LEFT ans) LEFT to RIGHT RANDOM RUNTIME
evaluated
ans) to make the
128 Use of parentheses in complexe expressions is necessary not permitted intended order of is aesthetic
evaluation clear
NO ROWS
129 Comparison of NULL with any other value evaluates ans) TRUE 0 RAISES syntax eror
FOUND
NO ROWS
130 Expression TRUE OR FALSE evaluates 0 ans) TRUE RAISES syntax eror
FOUND

ans) when checking for NULL when checking for


131 IS NULL operator is used not a valid command is equal to comparing with ''
values an empty string

132 Which of these are conversion functions TO_DATE TO_NUMBER TO_CHAR ans) All of the above
Converts either a number or a date to a character
133 ans) TO_CHAR TO_DATE TO_NUMBER TO_VARCHAR
string
134 Expression TRUE AND NULL evaluates to 1 0 ans) NULL RAISES syntax eror
135 Expression TRUE OR NULL evaluates to ans) TRUE 0 NULL RAISES syntax eror
X BETWEEN 1 AND ans) X=1 OR X=2
136 Condition X IN (1,2,3) is equallent to X=1 AND X=2 AND X=3 X >= 1 AND X<=3
3 OR X=3

137 Which is the right way of dealing with NULL values x=NULL ans) x IS NULL x='' x=' '

last two digits of the Removes the time


138 TRUNC(SYSDATE,'YYYY') gives ans) year Not a valid command
year portion
139
TO_CHAR(SYSDATE,'Mon') results if the sysdate is JAN ans) Jan JANUARY 9-Jan
12-JAN-2009
140 Which operator needs only one operand binary ans) unary Logical Arithmetic

ans) IF <condition> THEN IF <condition> THEN IF <condition> IF <condition>


<program_code> <program_code> <program_code> <program_code>
141 Which is the right syntax for IF statement ELSE ELSE ELSE ELSEIF
<program_code> <program_code> <program_code> <program_code>
END IF; END; END; END;

ans) FOR loop_index FOR loop_index


FOR loop_index IN IN FOR loop_index IN
low_value..high_value low_value..high_valu high_value..low_v high_value..low_value
142 The syntax for Loops LOOP e alue LOOP
<program_code LOOP LOOP <program_code
END LOOP; <program_code <program_code END;
END LOOP; END LOOP;

143 Does Oracle allow you to create your own functions ans) Yes No

144 Can you call functions from any PL/SQL code ans) Yes No
ans) GOTO GOTO is not a
145 Syntax for GO TO statement GO TO lable_name GO TO Exit
label_name valid statement

WHILE <condition is WHILE <condition


WHILE <condition is TRUE> LOOP
TRUE> is FALSE>
LOOP WHILE <condition is TRUE>
146 Syntax for While Loops LOOP LOOP
<statements> <statements>
<statements> <statements>
END LOOP; ENDLOOP;
ENDLOOP; ENDLOOP;

ans) might never While loop does not exists in Oracle


147 How many times must the WHILE loop execute Atleast once More than once
have to execute as in JAVA

148 Which command is used to exit from a simple LOOP EXIT EXIT WHEN ans) A & B Not needed

149
Can you potentially write a WHILE loop that never 0 ans) TRUE
WHILE loop
gives syntax error
ends always ends

150
What statement(s) allow you to abort the processing EXIT EXIT WHEN ans) A & B Not needed
of a loop
logically grouped
logically grouped set
ans) logically grouped set of set of stored logically grouped set of SQL
of database functions
151 A Procedure is a SQL and PL/SQL statements events that statements that perform a specific
that perform a
that perform a specific task perform a specific task
specific task
task
stored in the compilation is
ans) stored in the database and
152 A stored procedure is database as performed during
compiled
uncomiled run time
using remove
ans) using drop
153 How do you drop a procedure using a replace command procedure using del procedure command
procedure command
command
a procedure that goes into a procedure that ans) a procedure a procedure that does not have a
154 What is a recursive procedure
infinite loop always returns 1 that calls itself return statement
ALTER PACKGE
ALTER PACKGE <name>
155 How do you recompile a package <name> compile ans) A & B
compile body
package
156 Which of these are predefined exceptions no_data_found too_many_rows invalid_cursor ans) All of the above
157 Which of the below is a DML statement INSERT UPDATE DELETE ans) All of the above
158 Which of the below is a DDL statement COMMIT ROLLBACK CREATE ans) All of the above
Data dictionary Data driven
159 DDL statements means ans) Data definition language
language language
160 Which statement will implicitly issue a commit DELETE INSERT ans) TRUNCATE ROLLBACK
161 PL/SQL table functions COUNT EXISTS FIRST ans) All of the above
162 PL/SQL table functions last next prior ans) All of the above

163
What is the variable attribute you use to base a ans) %type %rowtype %recordtype %table of
variable on a table column
ans) variable with the It is a variable of variable with fixed number of
164 What is a PLSQL record It is a dynamic variable
type record type table columns
165 Which of these are Pseudo columns ROWNUM NEXTVAL ROWID ans) All of the above
166 Name a few implicit cursor attributes %FOUND %ROWCOUNT %NOTFOUND ans) All of the above
167 What are the types of cursors implict explicit ans) A&B defined
168 Which attribute tells the cursor is already in use ans) isopen %found %rowcount %open

169
Which attribute can tell the number of rows fetched %count ans)%rowcount %recordcount %total
so far for the cursor
A row in a table is A row in a table is
170 Triggers are fired in response to the following events A row is inserted into a table ans) All of the above
updated deleted
CREATE CREATE
171 The following are database privileges CREATE PROCEDURE ans) A&C
REDOFILES SESSION
172 Keyword DECLARE is used while defining ans) anonymous block procedure functions Packages
ans) tells SQL &
does not have any PLUS that we are used as a standard, semicolon can
173 Why do we type / at the end of PLSQL block to compile the code
meaning done typing be used instead
PLSQL code
ans) DBMS_OUTPUT.GE
174 Which command is used to display a line of text UTL_FILE.WRITE UTL_FILE.FOPEN
DBMS_OUTPUT.PUT_LINE T_LINE
175 Where does PL/SQL code execution take place Server Client ans) A & B

176
Oracle products such as Oracle Forms have the No ans) Yes
capability to execute PL/SQL code at client side
177
Which of these is a fundamental unit of PL/SQL variable function declare section ans) block
programming
178 Which of the below is not a PL/SQL data type VARCHAR2 NUMBER PLS_INTEGER ans) INT

179
What is the maximum size limit allowed for ans) 32767 2000 4000 No limit
VARCHAR2 variable in PL/SQL block
floading pointing
180 Number data type is used for declaring fixed point numbers ans) Both None
number
1008 decimal
181 Number data type allows maximum precision of There is no limit 108 demimal digits ans) 38 decimal digits
digits
the size and
ans) how many digits are used where the decimal
182 Precision in number data type specifies number of decimal none
to represent the number point is
points
the size and
how many digits are used to ans) where the
183 Scale in number data type specifies number of decimal none
represent the number decimal point is
points
unsigned integer
184 BINARY_INTEGER datatype is used for declaring ans) signed integer variables ans) both none
variables

185
Which data type is used to store strings of byte- LONG ans) RAW VARCHAR2 TYPE
oriennted data
186 Size of RAW data type in PL/SQL ans) 32767 255 block size 2000

ans) CREATE OR
REPLACE
CREATE OR
TRIGGER ans) CREATE OR REPLACE
CREATE OR REPLACE REPLACE
<trigger_name> TRIGGER <trigger_name>
TRIGGER <trigger_name> <trigger_name>
{BEFORE| {BEFORE|AFTER} verb_list ON
{BEFORE|AFTER} verb_list ON {BEFORE|AFTER}
AFTER} verb_list <table_name>
<table_name> verb_list ON
ON <table_name> FOR EACH ROW
187 Syntax for database triggers [FOR EACH ROW] <table_name>
[FOR EACH DECLARE
<variable list> [FOR EACH ROW]
ROW] <variable list>
BEGIN <variable list>
DECLARE BEGIN
<program_code> BEGIN
<variable list> <program_code>
END <program_code>
BEGIN END
END
<program_code>
END

188 Which of the below can be used in expression PROCEDURE ans) FUNCTION TRIGGER TABLE

189
While evaluating expressions, Oracle evaluates ans) FIRST LAST LEFT RIGHT
operators with a higher precedence
190
Which among these operators has highest AND BETWEEN Integer format ans) OR
precedence
compiles packages validates
191 execute dbms_utility.compile_all compiles invalid packages ans) recompiles all packages
in dbms_utility packages

192
Which exception is raised when PL/SQL encounters ans) program_error internal_error storate_error others
an internal erro
193
Conversion of a number to a character string failes value_error ans) invalid_number storate_error None
raises
Legal or not legal ans) Not legal because Not legal because Legal because
emp_rec_type must be emp_rec_type must emp_rec takes the
194 DECLARE
declared prior to this be declared after this type of
emp_rec emp_rec_type declaration declaration emp_rec_type

Legal or not legal ans) Not legal Legal because it


Not legal because it should because it should can reference any Legal because %type is new data
195 DECLARE
include table reference include table and table and column type available in higher versions
emp_last_name %type column reference type
Legal or not legal ans) Not legal
Legal because we
196
DECLARE Not legal because the table
are delaring a table
because the
TYPE emp_table is table of VARCHAR2(55); name is missing
type variable
INDEX BY clause
emp_dept_table emp_table_type; is missing

Difference between anonymous blocks and stored ans) stored Former has
Anonymous block is compiled procedure is declare Statement
197 procedures ? ans) A&C
only when it is called compiled only when and latter doesn’t.
it is called

truncate is
Why use Truncate over Delete while deleting all
198 truncate has an implicit commit it de allocates space efficient, triggers ans) All of the above
rows are not fired

ans) use “Execute immediate”


199 How do you run Native Dynamic SQL use "dbms_execute" use "utl_file"

200 Which of the belowISisTABLE


TYPE type_name not a predefined exception
OF element_type; dup_val_on_index not_logged_on login_dened ans) None
In the adove nested table
syntax,element_type can be PL/SQL datatype Ref Cursor and
201 except Binary_interger Varchar2 Boolean ANS)A & D

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 A,B,C ANS)B,C A,D,E D,E

203 Is it possible to use Commit/rollback in Exception ? ANS)YES NO

ANS)In Char type


spaces will be Both the cases
padded after 'name' the space will be In Char type spaces will be padded
Is there any diff between the below two statements upto max length padded after after 'name' uptp max length 20.in
a char(20) := 'name'; 20.in Varchar spaces 'name' upto max Varchar spaces will padded before
204 a Varchar(20) := 'name'; ? No difference. will not be padded length 20 'name' upto max length 20
After AS keyword we specify the
What is the difference between using IS and AS Using AS will return datatype. After IS
while creating a procedure, function package and ANS)There absolutely no Using IS will throw throw error while keyword we do the variable
205 package body? difference error compilation declaration
Functionality of Right OUTER JOIN is same as right
206 join. Is this statement true? No ANS)Yes
the inner query is
the outer query is executed first executed first and
and then inner query is then outer query is
excecuted for each value of excecuted for each exist is faster
207 Which statement is true about EXISTS Usage? outer query value of inner query than IN usage ANS)Option 1,3
In PL/SQL , we write select statement with INTO INVALID_CURSO
208 clause, this mat returns which all exceptions?? NO_DATA_FOUND TOO_MANY_ROWS R ANS)Option1,2
Is it possible to have same name for package and
209 the procedure in a package ANS)Yes No

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 1,2,3,4 ANS)1,3,4,2 3,4,1,2 2,1,4,3


Statement
What will happen to an anonymus block,if there is Comopiled
no statement inside the block? successfully.but No action is
211 ANS)Compilation error gives run time error performed

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
Trigger tr2 is fired
tr2 has insert (T) statement inside body of tr2 and a record is
Now, I'm tring to insert a row into T. Trigger tr1 is fired and the table ANS)will get a inserted into table
212 What will happen T is update mutating table error T

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? ANS)NUMBER NUMBER(T) LANG LANGRA

Declare V_sal
emp.sal % TYPE;
Declare V_sal emp.sal % Begin SELECT
TYPE; Sal INTO V_sal
Begin SELECT Sal INTO V_sal Declare V_sal FROM emp
FROM emp.sal % TYPE; WHERE empno = ANS)Declare V_sal emp.sal %
emp WHERE empno = and Begin SELECT Sal and P_empno; TYPE;
You need to update employee salaries if the salary P_empno; INTO V_sal FROM IF (V_Sal&lt;1000) Begin SELECT Sal INTO V_sal
of an employee is less than 1000.The salary needs IF (V_Sal&lt;1000) THEN emp WHERE empno THEN FROM emp WHERE empno = and
to be UPDATE emp INTO Sal := = and P_empno; UPDATE emp P_empno;
Sal*1.1 IF (V_Sal&lt;1000) Sal := Sal*1.1 IF (V_Sal&lt;1000) THEN
incremented by 10%. Use SQL*Plus substitution WHERE empno = and THEN WHERE empno = UPDATE emp Set Sal := Sal*1.1
variable to accept the employee number. Which P_empno; SAL := SAL * 1.1; and P_empno; WHERE empno = and P_empno;
214 PL/SQL block successfully updates the salaries? END IF;END; END IF;END; END IF; END; END IF; END;

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 Change the column ANS)Change the
dept_id is NULL Which change should you make to in the where operator in the Add a second condition to the where
215 achieve the desired result? Create an outer join. condition. where condition condition
Written a PL/SQL loop, you need to test if the
current FETCH was successful.Which SQL cursor This task cannot be accomplished
attribute would you use to ANS)SQL % with
216 accomplish this task? SQL % ISOPEN SQL % ROWCOUNT FOUND a SQL cursor attribute

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 ANS)DBMS_OUT
WHERE deptno=10; END Which statement displays DBMS_OUTPUT.PUT_LINE DBMS_OUTPUT.PU PUT.PUT_LINE DBMS_OUTPUT.PUT_LINE
217 the name of selected department? (name); T_LINE (dname); (dept_rec.name); (dept_rec.dname);

Evaluate this IF statement.


IF v_value&gt;100 THEN
v_new-value:=2*v-value;
ELSIF v-value&gt;200 THEN
v-new-value:=3*v-value;
ELSIF v-value&gt;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? 250 ANS)500 750 1000
DECLARE
TYPE emp-table
is TABLE of emp
BEGIN %ROWTYPE
TYPE emp-table is INDEX BY ANS)DECLARE
TABLE of emp WHOLE TYPE emp-table-type is TABLE of
DECLARE %ROWTYPE NUMBER; emp%ROWTYPE
How would you declare a PL/SQL table of records emp-table is TABLE of emp emp-table emp-table- emp-table emp- INDEX BY BINARY INTEGER;
219 to hold the rows selected from the EMP table? %ROWTYPE. type; table-type; emp-table emp-table-type;
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 A multiple selection A cursor for each
220 do you create? A cursor FOR loop. cursor. active set. ANS)A cursor that uses parameters.

You must explicitly You must explicitly


open the cursor close the cursor ANS)You do not explicitly open, fetch
Which statement is true when writing a cursor You must explicitly fetch the prior to the cursor prior to the end of or close a cursor within a cursor FOR
221 FORloop? rows within a cursor FOR loop. FOR loop. program. loop.

Programmers
ANS)Implicit cursors need to close all
are declared the implicit
Implicit cursors are declared implicitly for all the cursors before the Programmers can declare implicit
implicitly DML and SELECT end of the PL/SQL cursors by using the cursor type in
222 Which statement about implicit cursors is true? only for DML statements. statements. program. the declaration section

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? ANS)0 1 1 NULL

The data type in


the select list are
Select statement inconsistent with
Which two conditions in a PL/SQL block cause an Select statement does not returns more the data types in
224 exception error to occur? return a row. than one row. the into clause. ANS)Both A &B

ANS)DECLARE
v-hiredate
DATE:=SYSDATE
: DECLARE
DECLARE BEGIN v-hiredate DATE:=SYSDATE:
v_hiredate DATE:=SYSDATE: DECLARE INSERT INTO BEGIN
BEGIN v-hiredate emp(empnp,enam INSERT INTO
You need to create a PL/SQL program to insert INSERT INTO emp(empnp, DATE:=SYSDATE: e,hiredate) emp(empnp,ename,heridate,deptno)
ename, hiredate, deptno) BEGIN VALUES(empno_ VALUES(empno_sequence.nextval,
records into employee table. VALUES(empno_sequence.nex INSERT INTO sequence.nextval, 'and name',v_hitedate and deptno)
Which block of code successfully uses the insert tval, 'and name',v_hiredate and emp(empnp,ename,h name, v_hiredate) Job=Clerk
225 command? deptno) iredate,deptno) END: END:

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? 0 4 6 ANS)8

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
An order by
ORDER BY ANS)A where clause clause cannot
AVG(MONTHS_BETWEEN(SYSDATE,hire_date)); A select clause cannot contain cannot be used to contain a group A group function cannot contain a
227 Why does this statement cause an error? a group function. restrict groups. function. single row function.
In which section of a PL/SQL block is a user defined
228 exception waste? Heading ANS)Executable Declarative Exception handling

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 ANS)START
229 executes the code in the script file? Myproc.sql RUN myproc,sql myproc.sql EXECUTE myproc.sql
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&gt;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' || ANS)Variable Y is
TO_CHAR (Y); declared in the
Variable V_found is inner Variable V_sal is declared in the
END declared at block and outer
Why does this code produce an error when The value f V_found cannot be more than one referenced in the block and referenced in the inner
230 executed? YES. location. outer block. block.

Procedure cal_max(n1 NUBER n2


NUMBER, p_max OUT NUMBER)
ANS)Select IS
WHEN ename,sal BEGIN
NO_DATA_FOUND into If n1>n2 then
THEN v_ename,v_sal p_max:=n1;
Which statement is valid within the executable BEGIN DBMS_OUTPUT.PU from emp Else
section emp_rec emp%ROWTYPE T.LINE('No records where p_max=n2;
231 of Pl/SQL block? END; found'); empno=101; END.
In the declarative section of a PL/SQL block, you
It depends on the
created but did not initialize a number variable. scale and
When the block executes what will be the initial precision The block will not execute because
232 value of the variable? 0 ANS)NULL of the variable. the variable was not initialized.
ANS)Projection Projection allows
When selecting data which statement is valid about Projection allows due to choose allows due to due to joined Projection allows due to add columns
233 projection? rows. choose columns. tables together. to a table.

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 dept_table[15].loc := ANS)dept_table(1
234 statement makes this assignment? dept_table.loc.15 := 'Atlanta'; 'Atlanta'; 5).loc := 'Atlanta'; dept_table_type(15).loc := 'Atlanta';

ANS)UPDATE
emp
You need to change the job title Clerk to UPDATE emp SET job =
Job := 'Administrative 'Administrative UPDATE emp
Administrative Clerk UPDATE emp Clerk' WHERE Clerk' SET values job = 'Administrative
for all Clerks. SET job = 'Administrative UPPER (job) = WHERE UPPER Clerk'
235 Which statement does this? Clerk'; 'Clerk'; (job) = 'CLERK'; WHERE UPPER (job) = 'Clerk';

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; Terminating No FETCH
END; The cursor needs to be conditions are statements were ANS)The cursor does not need to be
236 Why does this section cause an error? opened. missing. issued. explicitly closed.

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
ANS)SELECT
PLAYER_BAT_STAT WHERE PLAYER_ID = V_ID; CALC_PLAYER_AVG(PLAYER EXECUTE
RETURN (V_AVG); END; Which statement will _ID) FROM CALC_PLAYER_AV CALC_PLAYER('
237 successfully invoke this function in SQL *Plus? PLAYER_BAT_STAT; G(31); RUTH'); START CALC_PLAYER_AVG(31);

You can view


whether an object
is valid or invalid
All schema objects in the
have a status that USER_OBJECTS
Which are true statements about An object with status of invalid is recorded in the data dictionary
238 dependent objects? cannot be a referenced object. data dictionary. view ANS)ALL the above
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? add_dept('Accountin add_dept(, 'New
239 add_dept; g'); York'); ANS)Exec add_dept;
A package is
You can pass loaded into ANS)You can achieve information
Which statements about packages parameters to memory each time hiding by making package constructs
240 are true? Packages can be nested. packages. it is invoked. private
Which two programming constructs can be grouped
241 within a package? Cursor Constant Trigger ANS)Both A &B
It does not persist
Which statements describe the state of a package ANS)It persists across It persists from across
variable after executing the package in which it is transactions session to session transaction within It persists from user to user when the
242 declared? within a session. for the same user. a session. package is invoked.

CREATE OR
REPLACE
TRIGGER
ANS)CREATE OR check_sal
REPLACE TRIGGER BEFORE
check_sal UPDATE OF sal
BEFORE UPDATE ON emp
OF sal ON emp WHEN (new.sal <
FOR EACH ROW old.sal OR
WHEN (new.sal < new.sal > old.sal * CREATE OR REPLACE TRIGGER
old.sal OR 1.1) check_sal
new.sal > old.sal * BEGIN AFTER UPDATE OR sal ON emp
1.1) RAISE_APPLICA WHEN (new.sal < old.sal OR
BEGIN TION_ERROR ( - -new.sal > old.sal * 1.1)
RAISE_APPLICATIO 20508, 'Do not BEGIN
N_ERROR ( - 20508, decrease RAISE_APPLICATION_ERROR ( -
ALTER TABLE emp ADD 'Do not decrease salary not 20508, 'Do not decrease
CONS TRAINT ck_sal CHECK salary not increase increase by more salary not increase by more than
Which code can you use to ensure that the salary is (sal BETWEEN sal AND by more than 10%'); than 10%'); 10%');
not increased by more than 10% at a time nor is it sal*1.1); END; END; END;
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 You can call the
BEGIN SELECT salary, commission_pct INTO ANS)You can call the BONUS.CALC_S
v_salary, v_bonus FROM BONUS.CALC_SAL ALARY packaged
employees WHERE employees RETURN v_bonus You can call the ARY packaged function form a You can call the
BONUS.CALC_SALARY function from DELETE BONUS.CALC_SALARY packaged
* v_salary + v_salary; packaged function from an a SELECT command command against function from an UPDATE
END cacl_salary; END bonus; / Which statement is INSERT command against against the the EMPLOYEES command against the EMPLOYEES
244 true? the EMPLOYEES table. EMPLOYEES table table table.

Use a drop Use a drop


procedure statement procedure For faster removal and re-creation,
to drop a procedure statement to drop do not use a drop procedure
that is part of a a procedure that statement. Instead, recompile the
package. is part of a procedure using the alter procedure
ANS)Use a drop procedure Then recompile the package. statement with the REUSE
Which statement is valid when removing statement to drop a standalone package Then recompile SETTINGS clause
245 procedures? procedure. specification the package body.

You need to create a trigger on the EMP table that


FOR EACH ROW
monitors every row that is changed and places this Statement-level trigger on the
information into the AUDIT_TABLE. ANS)FOR EACH ROW trigger trigger on the EMP AUDIT_TABLE Statement-level trigger on the
246 What type of trigger do you create? on the EMP table. table. table. AUDIT_TABLE table
If errors occur
If errors occur during during the
the compilation of a compilation of a
trigger you can go trigger you can
into SQL *Plus and use the SHOW
query the ERRORS ANS). If errors occur during the
If errors occur during the USER_TRIGGERS command within compilation of a trigger you can go
compilation of a trigger, the data dictionary view iSQL *Plus to see into SQL *Plus and query the
trigger to see the the compilation USER_ERRORS data dictionary
247 Which statements are true? is still created. compilation errors. errors. view to see compilation errors
ANS)USER_DEP
248 Which dictionary view track dependencies? USER_SOURCE UTL_DEPTREE ENDENCIES DBA_DEPENDENT_OBJECTS

You need to
Given a function CALCTAX: CREATE OR create a SQL
REPLACE FUNCTION calctax (sal NUMBER) *Plus environment
You need to execute variable X and ANS)You need to create a SQL
RETURN NUMBER IS BEGIN RETURN (sal * 0.05); You need to execute the the command issue the *Plus environment variable X and
END; If you want to run the above function from the command EXECUTE command :X := issue the command EXECUTE :X :=
249 SQL *Plus prompt, which statement is true? CALCTAX(1000);. FUNCTION calctax;. CALCTAX(1000);. CALCTAX(1000);
An area of
memory is
What happens during the execute phase with The validity of the established ANS)The SQL statement is run and
dynamic SQL for INSERT, UPDATE, and DELETE The rows are selected and SQL statement to process the the number of rows processed is
250 operations? ordered. is established SQL statement. returned.
What part of a database trigger determines the
251 number of times the trigger body executes? ANS)Trigger type Trigger body Trigger event Trigger timing

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 The statement
gen_email_name(first_name, last_name, 108) ANS)The statement fails because the The SQL statement executes
Employee 108 has his email fails because functions successfully, because UPDATE and
EMAIL name updated functions called from does not contain DELETE statements are ignoring in
FROM employees; based on the return result of SQL expressions code to end the stored functions called from SQL
252 What occurs? the function. cannot perform DML transaction. expressions
Which table should you query to determine when ANS)USER_OBJ
253 your procedure was last compiled? USER_PROCEDURES USER_PROCS ECTS USER_PLSQL_UNITS

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;
/ System event
254 What type of trigger is it? ` DML trigger INSTEAD OF trigger trigger ANS)This is an invalid trigger
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 The value of
discount_rate := 0.10; DISCOUNT_RAT
END discounts; The value of E is set to 1.00
DISCOUNT_RATE is each time the ANS)The value of
/ The value of set to 0.10 each procedure DISCOUNT_RATE is set to 0.10
Which statement is true? DISCOUNT_RATE always time the package is DISPLAY_PRICE when the package is invoked for the
255 remains 0.00 in a session. invoked in a session. is invoked. first time in a session

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 A value equal to the number of rows
256 AUDIT_TABLE? ANS)1 10 NONE in the EMP 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 %ROWTYPE PL/SQL table of
257 emp table? PL/SQL record. variable scalars. ANS)PL/SQL table of records.
The package
The specification and specification is
ANS)The specification and body of the package optional,
body of the package are stored are stored together in but the package Both the specification and body are
258 Which statements about packages are true? separately in the database the database body is required. required components of a package

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 SHOW ANS)SHOW
259 error message? SHOW FUNCTION_ERROR USER_ERRORS ERRORS SHOW ALL_ERRORS
A specific user or
A specific error or any errors A database is shut any user logs on
260 Which triggering events can cause a trigger to fire? occurs down or started up. or off. ANS)ALL THE ABOVE

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 RUN
UPD_BAT_STAT EXECUTE ANS)UPD_BAT_STA UPD_BAT_STAT(
261 procedure? UPD_BAT_STAT(V_ID); T(V_ID); V_ID); START UPD_BAT_STAT(V_ID);

ANS)You use a You use a system


You use an application trigger database trigger to event trigger to
to fire fire fire
when a DELETE statement when an INSERT when an UPDATE You use INSTEAD OF trigger to fire
262 Which statement about triggers is true? occurs statement occurs. statement occurs. when a SELECT statement occurs.

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. A s0tandalone
What is the most appropriate location to store the ANS)A stored procedure on the A block of code in a procedure on the A block of code in the body of the
263 code that calculates the discounts? server. PL/SQL library. client machine. program unit ORDERTOTAL
Which type of argument passes a value from a
264 procedure to the calling environment? VARCHAR2 BOOLEAN ANS)OUT IN
You create a DML trigger. For the timing
information,
265 which is valid with a DML trigger? DURING INSTEAD ON SHUTDOWN ANS)BEFORE

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 ANS)USER_DEPEN USER_REFEREN
266 invoke the CALC_TEAM_AVG function? USER_PROC_DEPENDS DENCIES CES USER_SOURCE
A CALL statement inside the trigger body enables ANS)A stored
267 you to call A package A stored function procedure Another database trigger
You need to remove the database trigger
BUSINESS_HOUR. REMOVE
Which command do you use to remove the trigger in ANS)DROP TRIGGER DELETE TRIGGER TRIGGER ALTER TRIGGER business_hour
268 the SQL *Plus environment? business_hour; business_hour; business_hour; REMOVE;
Use the Use the Use the
How can you migrate from a LONG to a LOB data DBMS_MANAGE_LOB.MIGRA UTL_MANAGE_LOB DBMS_LOB.MIG
type TE .MIGRATE RATE ANS)Use the ALTER TABLE
269 for a column? procedure. procedure procedure command.

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); EXECUTE
COMMIT; INSERT_TEAM
EXECUTE (3, ANS)EXECUTE
END INSERT_TEAM (3, V_NAME=>'LONGH INSERT_TEAM(3,
Which statements will successfully invoke this 'LONGHORNS'); ORNS', 'AUSTIN','LONGH
270 procedure in SQL *Plus? V_CITY=>'AUSTIN'); ORNS'); BOTH B AND C

The executable
section of a stored
procedure
contains
ANS)A stored statements that
procedure has three assigns values,
parts: control
A stored procedure is a type of the specification, the execution,and
PL/SQL body, and the return values to
subprogram that performs an exception handler the calling A stored procedure is typically
272 Which describe a stored procedure? action. part. environment. written in SQL.

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 EXECUTE EXECUTE


you now invoke the procedure in SQL *Plus. ANS)EXECUTE add_dept('Education' add_dept('2500', EXECUTE add_dept
273 Which is not valid invocations? add_dept(p_loc=>2500) , 2500) p_loc =>2500) (p_name=>'Education', 2500)
Declaring
ANS)Specifying variables with the
Which is not a valid way to minimize dependency Querying with the SELECT * schema names when %TYPE Declaring records by using the
274 failure? notification. referencing objects. attribute. %ROWTYPE attribute
The package
Which dopes the INSTEAD OF clause in a trigger The view associated with the The table associated associated with The statement level or for
275 identify? trigger with the trigger the trigger. each row association to the trigger.
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? ANS)UPDATE_S
276 CALC_TAX INSERT_EMP AL DELETE_EMP

Use the Use the


DBMS_LOB.BFILEN DBMS_LOB.FILE
Use the DBMS_LOB.WRITE AME function to EXISTS function ANS)Use the
procedure to locate an external to find the location DBMS_LOB.FILECLOSE procedure
277 What can you do with the DBMS_LOB package? write data to a BFILE BFILE. of a BFILE. to close the file being accessed.

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 g_comm has a
value of 20 at
User Smith executes the following code at 9:05am: g_comm has a value of 15 at ANS)g_comm has a 9:06am
EXECUTE comm_paclage.g_comm := 20 9:06am value of 15 at for both Jones g_comm has a value of 15 at 9:03
278 Which statement is true? for Smith. 9:06am for Jones. and Smith. am for both Jones and Smith.
ANS)DROP FUNCTION REMOVE DELETE
279 Which statement removes the function? gen_email_name; gen_email_name; gen_email_name; NONE

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;
EXECUTE
END; UPD_BAT_STAT(
Which two statements will successfully invoke this UPD_BAT_STAT(V_ V_AB=>10,
280 procedure in SQL *Plus? EXECUTE UPD_BAT_STAT; AB=>10, V_ID=>31); V_ID=>31); ANS)BOTH AND C

Examine this code: CREATE OR REPLACE


PROCEDURE audit_action
The trigger
(p_who VARCHAR2) AS BEGIN INSERT INTO invoked the
audit(schema_user) VALUES(p_who); END procedure
audit_action; / CREATE OR REPLACE TRIGGER audit_action each
watch_it AFTER LOGON ON DATABASE CALL The trigger marks the time a user logs
The trigger records an audit user as logged on on to his/her ANS)The trigger invokes the
audit_action(ora_login_user) / What does this trail to the database schema and adds procedure audit_action each time
trigger do? when a user makes changes to before an audit the username to a user logs on to the database and
281 the database. statement is issued. the audit table adds the username to the audit table.

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 OPEN ANS)OPEN
... emp_cursor('clerk',10 emp_cursor(10,
282 Which statement opens the cursor successfully? OPEN emp_cursor. ); 'analyst'); OPEN emp_cursor (p_deptno,p_job);
The OLD and NEW qualifiers can be used in which ANS)Row level Statement level
283 type of trigger? Row level DML trigger application trigger DML trigger Row level system trigger

ANS)Stored
functions can
increase the
efficiency of
queries by
performing
Stored functions can functions
Stored functions do not permit be called from the in the query rather
calculations that involve SELECT and than in the Stored functions cannot manipulate
database links in a distributed WHERE clauses application new types of data, such as longitude
284 Which statement is true? environment. only. and latitude

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 ANS)Change the Take out the
Remove the DBMS_OUTPUT trigger to a COUNT function
statement is entered: statement statement-level because
DELETE FROM Emp_tab WHERE Empno = 7499; because it is not allowed in a trigger by removing it is not allowed in Change the trigger type to a
285 How do you correct the error? trigger. FOR EACH ROW a trigger. BEFORE DELETE.

A stored procedure is
named PL/SQL block ANS)A stored
with at least one procedure must
A stored procedure uses the parameter have at least
DELCLARE keyword in the declaration in the one executable A stored procedure uses the
procedure specification to procedure statement in the DECLARE keyword in the procedure
286 What is true about stored procedures? declare formal parameters. specification. procedure body. body to declare formal parameters.
The creation of which database objects will
287 not cause a DDL trigger to fire? ANS)Synonyms Index Cluster Package

CREATE OR
REPLACE
ANS)CREATE OR FUNCTION
CREATE OR REPLACE REPLACE tax_amt CREATE OR REPLACE
PROCEDURE tax_amt FUNCTION tax_amt (p_id NUMBER) PROCEDURE tax_amt
(p_id NUMBER) (p_id NUMBER) RETURN (p_id NUMBER, p_amount OUT
Which two program declarations are RETURN NUMBER RETURN NUMBER NUMBER(10,2) NUMBER(10, 2))
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? ANS)System event INSTEAD OF
289 DML trigger trigger trigger Application trigger

You have a row level BEFORE UPDATE trigger on ANS)The trigger


the EMP table. This trigger contains a SELECT fails because a
statement on the EMP table to ensure that the new The trigger fails SELECT
because it needs statement on the The trigger fails because you cannot
salary value falls within the minimum and maximum to be a row level table being use the minimum and
salary for a given job title. What happens when you AFTER UPDATE updated is not maximum functions in a BEFORE
290 try to update a salary value in the EMP table? The trigger fires successfully. trigger. allowed. UPDATE trigger

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; This statement This statement
returns a raise creates a stored
RETURN v_raise; amount function named
END; This statement creates a stored based on an get_sal with a
291 Which statement is true? procedure named get_sal. employee id. status of invalid. ANS)This statement fails.

ALTER TRIGGERS ANS)ALTER None of these commands; you


You need to disable all triggers on the ON TABLE TABLE employees cannot disable
EMPLOYEES table. ALTER employees DISABLE employees DISABLE ALL multiple triggers on a table in one
292 Which command accomplishes this? ALL TRIGGERS; DISABLE; TRIGGERS; command

A file stored outside of the database,


ANS)Stored in the A column that is a with an internal pointer to it from a
293 An internal LOB is _____. A table. database. primary key. database column.
Examine this code:
CREATE OR REPLACE FUNCTION
calc_sal(p_salary NUMBER)
RETURN NUMBER
IS
v_raise NUMBER(4,2) DEFAULT 1.08;
BEGIN DELETE FROM
RETURN v_raise * p_salary; INSERT employees(calc_s
END calc_sal; UPDATE employees calc_sal(salary) al(salary)) ANS)SELECT salary,
(calc_sal(salary)) INTO employees WHERE calc_sal(salary)
/ SET salary = salary * WHERE calc_sal(salary) > FROM employees
Which statement accurately call the stored function calc_sal(salary); department_id = 60; 1000; WHERE department_id = 60;
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 ORACLE FORM
295 correct the error? ANS)Row Statement trigger Before

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 If you remove the
p_weight_in_pounds * c_weight END calc_weight package body, then
END metric_converter; / CREATE OR REPLACE the package
FUNCTION calc_height (p_height_in_inches ANS)If you remove the specification and the If you remove the
package specification, then the stand alone stored package
NUMBER) RETURN NUMBER IS BEGIN RETURN package body and the stand function specification, If you remove the package body,
p_height_in_inches * metric_converter.c_height; alone stored function CALC_HEIGHT are then the package then the package specification is
296 END calc_height; / Which statement is true? CALC_HEIGHT are removed. removed body is removed removed.

ANS)A conditional
A conditional predicate allows
A conditional predicate allows predicate means you you to combine
you to use the NEW and several DBM A conditional predicate allows you to
specify a WHEN-LOGGING- OLD qualifiers in the triggering events specify a SHUTDOWN
ON condition in the trigger trigger body as a into one in the or STARTUP condition in the trigger
297 What is a condition predicate in a DML trigger? body. condition. trigger body. body.

GRANT SELECT,
INSERT, UPDATE,
DELETE GRANT
Which command must you issue to allow users to ANS)GRANT SELECT, ON EXECUTE ON GRANT SELECT, EXECUTE ON
access the UPD_TEAM_STAT trigger on the TEAM INSERT, UPDATE, DELETE UPD_TEAM_STAT TEAM TO TEAM,
298 table? ON TEAM TO PUBLIC; TO PUBLIC; PUBLIC UPD_TEAM_STAT TO PUBLIC;
When creating a function, in which section will you ANS)EXECUTAB DECLARATIVE,EXECUTABLE and
299 typically find the RETURN keyword? HEADER only DECLARATIVE LE and HEADER EXCEPTION HANDLING
In which section of a PL/SQL block is a user defined
300 exception raised? Heading. ANS)Executable Declarative Exception handling.
ANS)A variable A variable defined A variable is in an inner block may
Variable name must be unique defined in the outer in the inner block have the same name as a variable in
between blocks. block is visible in the is visible in the an outer block only if the data
301 Which statement is true about nesting blocks? inner blocks. outer blocks. types are different.

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 By inserting the
above block of code is executed. By inserting the statement
statement DBMS_OUTPUT. ANS)By inserting the statement
How can u trace the values of counter variable i and DBMS_OUTPUT.PU DEBUG_VAR (i , DBMS_OUTPUT.PUT_LINE (i | | ``| |
date variable v_date in SQL* By setting SQL* PLUS session T_LINE (i , v_date); v_date); TO_CHAR( v_date));
302 PLUS environment? variable DEBUGGER=TRUE Between lines 8-9 Between lines 8-9 Between lines 8-9
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 ANS)IF
compilation error when above PL/SQL block is v_name emp.ename (v_sal.GT.10000) This code displays salaries
303 executed? v_num NUMBER; %TYPE; THEN if larger than 10000.

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 ANS)ALL_OBJECTS DBA_SEGMENTS
304 this information? USER_OBJECTS. . . DBA_TABLES.

ANS)Last name
You query the database with this and first name of
command.SELECT last_name, first_nameFROM Last name and first all the employees
employeeWHERE SALARY IN SELECT salary name of all the with the same
employees salary as Last name and first name of only the
FROM employee WHERE dept_no=3 OR Last name and the first name of except those employee in the employees whose salary falls in the
dept_no=5); only the employees in the working in the department 3 and range of salary from
305 Which values are displayed? department number 3 and 5. department 3and 5. 5. department 3 or 5.
Which operator is not appropriate in the joined
condition of none equijoin select ANS)Equal
306 statement? In operator. Like operators operators. Between x and y operator.
What should you do after each fetch statement in ANS)Test for the rows using the
307 the PL/SQL block? Open the cursor. Close the cursor Initialize the loop. cursor attribute.

ANS)SELECT
last_name,salary
Which SELECT statement would you use in a INTO
SELECT v_last_name,v_sal SELECT l last_name,salary
PL/SQL block to query the employee table and last_name,salary ary FROM employee;
retrieve the last name and salary of the employee SELECT last_name,salary FROM employee; FROM employee INTO v_last_name,v_salary
308 whose ID is 3? FROM employee; WHERE id=3; WHERE id=3; WHERE id=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, ANS)You can't
name VARCHER(20)); retrieve the entire SELECT*
dept_rec dept_record_type; SELECT row using the INTO
SELECT* deptno,dname,loc DEPT_REC dept_rec.dno,dept_rec.name,dept_re
How do you retrieve an entire row of the DEPT table INTO dept_rec INTO dept_rec variable c.
using the DEPT-REC FROM dept FROM dept declared in the FROM dept
309 variable? WHERE dept no=10; WHERE dept no=10; code. WHERE dept no=10;

DECLARE
CURSOR emp-
cursor 1S
Examine the code: DECLARE. CURSOR SELECT
emp_cursor ISSELECT ename,deptno DECLARE ename,dept no
CURSOR emp- FROM emp;
FROM emp; emp_rec emp_cursor %ROWTYPE cursor 1S BEGIN
BEGIN OPEN emp_cursor SELECT ename,dept FOR emp-rec IN DECLARE
LOOP ANS)DECLARE no emp-cursor LOOP CURSOR emp-cursor 1S
FETCH emp_cursor CURSOR emp-cursor 1S FROM emp; OPEN emp- SELECT ename,dept no
INTO emp_rec SELECT ename,dept no BEGIN cursor; FROM emp;
FROM emp; FOR emp-rec IN INSERT INTO emp-rec emp-cursor%ROWTYPE;
EXIT WHEN emp_cursor NOT FOUND; BEGIN emp-cursor LOOP temp- BEGIN
INSERT INTO temp_emp(name'dno) FOR emp-rec IN emp-cursor OPEN emp-cursor; emp(name,dno) FETCH emp-cursor
VALUES(emp_rec.ename,emp_rec deptno); LOOP INSERT INTO temp- VALUES (emp- INTO emp-rec;
END LOOP; INSERT INTO temp- emp(name,dno) rec.ename, FOR emp-recIN emp-cursor LOOP
CLOSE emp_cursor; emp(name,dno) VALUES (emp- emp-rec.deptno); INSERT INTO temp-emp(name,dno)
VALUES (emp-rec.ename, rec.ename, END LOOP VALUES (emp-rec.ename,
END; emp-re.deptno); emp_rec.deptno); CLOSE emp- emp-rec.deptno);
Using a cursor FOR loop,which PL/SQL block END LOOP END LOOP cursor; END LOOP
310 equivalent to the above code? END; END; END; END;
When a delete ANS)When a
statement in a select statement
When any DML or select PL/SQL block in a PL/SQL block When an update statement in a
Under which situation it is necessary to use an statement deletes more than is more than one PL/SQL block has to modify more
311 explicit cursor? is used in a PL/SQL block one row. row. than one row.
Which data dictionary view contains the definition of
312 a view? MY_VIEWS. ANS)USER_VIEWS. SYSTEM_VIEWS. USER_TAB_VIEWS.

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? 0 ANS)1 2 3
some of same
data type and
A collection is an ordered group of elements all of different data some of different
314 of -------------------------- ANS)all of the same data type type data type none

315 Which is a pl/sql collection type Index-by tables Nested tables Varrays ANS)all the above
ANS)associative
316 Index by table is also known as varrays arrays Nested tables none
Index by table let you lok up elements using ------- sequential
317 for subscript values arbitrary numbers strings numbers ANS)both a and b
Nested table let you lok up elements using ------- ANS)sequential
318 for subscript values arbitrary numbers strings numbers both a and b
Which PL/SQL collection type will use sequential
319 numbers as subscript types Index-by tables Nested tables Varrays ANS)both b and c
Which PL/SQL collection type will hold fixed number
320 of elements Index-by tables Nested tables ANS)Varrays both b and c

321 PL/SQL collection types can be declared in procedure Function Package ANS)All the above
Which PL/SQL data type can be stored as a column
322 in a data base table ANS)nested tables Associative array Both a and b none

323 Nested Tables cannot use the following data types BINARY_INTEGER SIGNTYPE STRING ANS)all the above
which PL/SQL collection type does not need
324 Constructors ANS)Index-by tables Nested tables Varrays None

325 Which PL/SQL collection needs a constructor Index-by tables Nested tables Varrays ANS)Both b and c
If the subscript of a PL/SQL collection is null,or is
not convertable to the right datatype then it throws SUBSCRIPT_BEYON SUBSCRIPT_NUL
326 the following exception ANS)VALUE_ERROR D_COUNT. L COLLECTION_IS_NULL
If the subscript of a PL/SQL collection refers to an ANS)SUBSCRIPT_B SUBSCRIPT_NUL
327 uninitialized element, PL/SQL raises VALUE_ERROR EYOND_COUNT. L COLLECTION_IS_NULL
SUBSCRIPT_BEYO SUBSCRIPT_NUL
328 If the collection is atomically null, PL/SQL raises VALUE_ERROR ND_COUNT. L ANS)COLLECTION_IS_NULL
Associative arrays cannot use the following
329 collection methods Exists Trim Limit ANS)Both and b

330 Which collection method is a procedure EXTEND TRIM DELETE ANS)All the above

331 Which collection method is a function EXTEND EXISTS PRIOR ANS)BOTH B AND C
Which collection method can be applied to
332 automatically null collections ANS)Exists Extend Prior Count
Which collection method returns TRUE if the nth
333 element in a collection exists Extend(n) ANS)Exists(n) Next(n) Count

IF
Which Syntax is correct for Counting the elements ANS)IF projects.COUNT = 25 COUNT(projects) =
334 in a PL/SQL collection THEN IF COUNT = 25 THEN 25 THEN IF COUNT(*) = 25 THEN
which Pl/SQL collection method will return NULL for
335 nested tables and associative arrays Count Exists ANS)Limit Extends

which PL/SQL collection method returns the index


336 number that precedes index n in a collection Extends(n) ANS)Prior(n) Next(n) First(n)

337 Subscript range for nested tables is ANS)1 .. 2**31 1 ..  size_limit -2**31 .. 2**31 none

338 Subscript range for varrays is 1 .. 2**31 ANS)1 ..  size_limit -2**31 .. 2**31 none
Subscript range for associative arrays with numeric ANS)-
339 key 1 .. 2**31 1 ..  size_limit 2**31 .. 2**31 none
We can check
whether two greater than
ANS)We can check whether a collections are the operator between less than operator between two
340 Which is allowed for a PL/SQL collections collection is null same two collections collections

341 Pl/SQL collections cannot appear in ----------list Distinct Group By Order By ANS)All the above
LIMIT returns the maximum number of elements
that the collection can contain for which Pl/SQL
342 collection type Nested tables Associative array ANS)Varrays None
Which PL/SQL collection method returns the
343 smallest Index number in a collection Count Limit Last ANS)First
Which PL/SQL collection method returns the largest
344 index number in a collection Count Limit ANS)Last First
If the collection is empty First and Last Pl/SQL
345 collection methods return 0 ANS)Null 1 None
Which PL/SQL method returns the index number
346 that succeeds index n. Extends(n) Prior(n) ANS)Next(n) Last(n)
Which PL/SQL method is used to remove one
347 element from the end of a collection ANS)TRIM TRIM(n) DELETE DELETE(n)
Which PL/SQL method is used to remove n
348 elements from the end of a collection TRIM ANS)TRIM(n) DELETE DELETE(n)
Which PL/SQL method is used to remove all
349 elements from a collection TRIM TRIM(n) ANS)DELETE DELETE(n)
Which PL/SQL method removes the nth element
350 from an associative array with a numeric key TRIM TRIM(n) DELETE ANS)DELETE(n)
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