How To Control How Many Cursors Are Open in An Session: Q UE ST IO N #
How To Control How Many Cursors Are Open in An Session: Q UE ST IO N #
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
UPDATE emp_sal@db_link2
SET BALANCE = BALANCE + 100
WHERE emp_id=1001;
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
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
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
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
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;
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
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
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
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
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
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=' '
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
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
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
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<1000) Begin SELECT Sal INTO V_sal
of an employee is less than 1000.The salary needs IF (V_Sal<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<1000) Sal := Sal*1.1 IF (V_Sal<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;
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
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:
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';
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?
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
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
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.
END add_dept;
/
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
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
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?
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.
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.
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;
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.
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
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