PLSQL Question
PLSQL Question
UPDATE emp_sal@db_link2
SET BALANCE = BALANCE + 100
WHERE emp_id=1001;
9
You cannot grant privileges on remote objects to
other users.
10
Which of the following operations cannot be
performed using database links to a remote
11 database.
A) Grant privileges on remote objects
B) Execute DESCRIBE operations on remote
procedure
89
90 Which of the following is not a aggregate functions?
What is the lifetime of a user-defined variable?
91
Which of the following commands can be used to
interrupt processing of a While loop?
92
151 A Procedure is a
210
What will happen to an anonymus block,if there is
no statement inside the block?
211
END display_price;
BEGIN
discount_rate := 0.10;
END discounts;
/
Which statement is true?
255
CREATE OR REPLACE TRIGGER update_emp
AFTER UPDATE ON emp
BEGIN
INSERT INTO audit_table (who, dated)
VALUES (USER, SYSDATE);
END;
You issue an UPDATE command in the EMP table
that results in changing 10 rows.
How many rows are inserted into the
256 AUDIT_TABLE?
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
User Smith executes the following code at 9:05am:
EXECUTE comm_paclage.g_comm := 20
278 Which statement is true?
279 Which statement removes the function?
IS
v_salary NUMBER;
v_raise NUMBER(8,2);
BEGIN
SELECT salary
INTO v_salary
FROM employees
WHERE employee_id = p_employee_id;
v_raise := p_raise_amt * v_salary;
RETURN v_raise;
END;
291 Which statement is true?
1 2
There is no absolute limit to the total
ANS)Set OPEN_CURSORS parameter in number of cursors one session can
initialization parameters have open at one time
ANS)50 25
2,4 2,3,4
ANS)PMON SMON
PMON SMON
1 2
You do not have the UPDATE object ANS) Scott does not have the UPDATE
privilege on the EMP_SAL table. object privilege on the EMP_SAL table
ANS)TRUE 0
ANS)TRUE 0
By using block labels, you can give a
Anonymous blocks don't have names under name to your block for the duration of
which they can be stored in the database its execution, using PL/SQL labels .
ANS)Triggers Functions
0 ANS)TRUE
Synonym ANS)Views
1000 512
ANS)TRUE 0
Inline view is a subquery that appears in the Inline view is enclosed in parenthesis
from clause of the select statement and may be given an alias name.
You cannot specify a BEFORE trigger on a You cannot perform DML with BEFORE
view or an object view trigger
You cannot specify an AFTER trigger on a You cannot write either the :OLD or
view or an object view the :NEW value.
You can read both the :OLD and
INSTEAD OF triggers are valid only for the :NEW value, but you cannot write
views. either the :OLD or the :NEW value.
SQLERROR SQLCODE
1 0
ANS)TRUE 0
Cannot use comparision operators to
test cursor variable for
Cannot assign NULL to curosr variable equality,inequality or nullity
%ROWCOUNT %CURSOROPEN
Declarative Part Definition Part
ANS)%ROWTYPE %TYPE
The cursor having query as SELECT .... The cursor having query as SELECT....
FOR UPDATE gets closed after does not get closed even after
COMMIT/ROLLBACK COMMIT/ROLLBACK.
Triggering event Triggering action
INSERT DELETE
ANS)NO YES
User_objects user_source
ANS)PRAGMA_EXCEPTION_INIT EXCEPTION
PRAGMA_EXCEPTION_INIT EXCEPTION
IN OUT
Procudute is called as a part of an ANS)Procedure is called as plsql
expression . Functions are called as a plsql statement.Function is called as a part of
statement an expression
ANS)TRUE 0
Object privilege Role privilege
ANS)INSERT & UPDATE INSERT & DELETE
USER_DB_LINKS ALL_DEPENDENCIES
100 10
Views require as much space as all the tables Views require as much space as would a
they are created from. table that presented the same data.
No difference
DBMS_OUTPUT DBMS_SQL
ans) block structured language unstructed langugage
variable declarations program code
other PL/SQL blocks error handlers
To handle errors ans) to display the output
CREATE TYPE CREATE TRIGGER
delimeter quote
Yes ans) No
ans) Yes No
BEGIN END
= ans) :=
No rows Multiple
ans) Variable length character strings Character string with 2 bytes size
NUMBER BINARY_INTEGER
ILLEGAL WRONG_DATA_TYPE
ans) No Yes
FUNCTION PROCEDURE
LOWER UPPER
ans) TRUE 0
0 ans) TRUE
ans) when checking for NULL values not a valid command
TO_DATE TO_NUMBER
ans) TO_CHAR TO_DATE
1 0
ans) TRUE 0
X=1 AND X=2 AND X=3 X BETWEEN 1 AND 3
x=NULL ans) x IS NULL
ans) year last two digits of the year
JAN ans) Jan
binary ans) unary
ans) IF <condition> THEN IF <condition> THEN
<program_code> <program_code>
ELSE ELSE
<program_code> <program_code>
END IF; END;
FOR loop_index ans) FOR loop_index IN
low_value..high_value low_value..high_value
LOOP LOOP
<program_code <program_code
END LOOP; END LOOP;
ans) Yes No
ans) Yes No
GO TO lable_name ans) GOTO label_name
WHILE <condition is TRUE> WHILE <condition is TRUE>
LOOP LOOP
<statements> <statements>
END LOOP; ENDLOOP;
ans) stored in the database and compiled stored in the database as uncomiled
a procedure that goes into infinite loop a procedure that always returns 1
ALTER PACKGE <name> compile
ALTER PACKGE <name> compile body
package
no_data_found too_many_rows
INSERT UPDATE
COMMIT ROLLBACK
ans) Data definition language Data dictionary language
DELETE INSERT
COUNT EXISTS
last next
ans) %type %rowtype
ROWNUM NEXTVAL
%FOUND %ROWCOUNT
implict explicit
ans) isopen %found
%count ans)%rowcount
A row is inserted into a table A row in a table is updated
CREATE PROCEDURE CREATE REDOFILES
ans) anonymous block procedure
No ans) Yes
variable function
VARCHAR2 NUMBER
AND BETWEEN
compiles invalid packages compiles packages in dbms_utility
ans) program_error internal_error
value_error ans) invalid_number
ans) Not legal because emp_rec_type must Not legal because emp_rec_type must
be declared prior to this declaration be declared after this declaration
Not legal because it should include table ans) Not legal because it should include
reference table and column reference
Anonymous block is compiled only when it is ans) stored procedure is compiled only
called when it is called
dup_val_on_index not_logged_on
Binary_interger Varchar2
A,B,C ANS)B,C
ANS)YES NO
ANS)In Char type spaces will be
padded after 'name' upto max length
No difference. 20.in Varchar spaces will not be padded
No ANS)Yes
the outer query is executed first and then the inner query is executed first and
inner query is excecuted for each value of then outer query is excecuted for each
outer query value of inner query
NO_DATA_FOUND TOO_MANY_ROWS
ANS)Yes No
1,2,3,4 ANS)1,3,4,2
Trigger tr1 is fired and the table T is update ANS)will get a mutating table error
ANS)NUMBER NUMBER(T)
Declare V_sal emp.sal % TYPE;
Begin SELECT Sal INTO V_sal FROM Declare V_sal emp.sal % TYPE;
emp WHERE empno = and P_empno; Begin SELECT Sal INTO V_sal FROM
IF (V_Sal<1000) THEN emp WHERE empno = and P_empno;
UPDATE emp INTO Sal := Sal*1.1 IF (V_Sal<1000) THEN
WHERE empno = and P_empno; SAL := SAL * 1.1;
END IF;END; END IF;END;
BEGIN
TYPE emp-table is TABLE of emp
DECLARE %ROWTYPE
emp-table is TABLE of emp%ROWTYPE. emp-table emp-table-type;
You must explicitly fetch the You must explicitly open the cursor
rows within a cursor FOR loop. prior to the cursor FOR loop.
ANS)0 1
0 4
Heading ANS)Executable
Myproc.sql RUN myproc,sql
UPDATE emp
UPDATE emp Job := 'Administrative Clerk' WHERE
SET job = 'Administrative Clerk'; UPPER (job) = 'Clerk';
ANS)SELECT
CALC_PLAYER_AVG(PLAYER_ID) FROM
PLAYER_BAT_STAT; EXECUTE CALC_PLAYER_AVG(31);
An object with status of invalid All schema objects have a status that
cannot be a referenced object. is recorded in the data dictionary.
add_dept; add_dept('Accounting');
Cursor Constant
ANS)CREATE OR REPLACE
TRIGGER check_sal
BEFORE UPDATE OF sal ON emp
FOR EACH ROW
WHEN (new.sal < old.sal OR
new.sal > old.sal * 1.1)
BEGIN
RAISE_APPLICATION_ERROR ( -
ALTER TABLE emp ADD 20508, 'Do not decrease
CONS TRAINT ck_sal CHECK (sal salary not increase by more than 10%');
BETWEEN sal AND sal*1.1); END;
ANS)You can call the
You can call the BONUS.CALC_SALARY BONUS.CALC_SALARY packaged
packaged function from an INSERT function from
command against a SELECT command against the
the EMPLOYEES table. EMPLOYEES table
You need to execute the command You need to execute the command
CALCTAX(1000);. EXECUTE FUNCTION calctax;.
USER_PROCEDURES USER_PROCS
DML trigger INSTEAD OF trigger
You use an application trigger to fire ANS)You use a database trigger to fire
when a DELETE statement occurs when an INSERT statement occurs.
VARCHAR2 BOOLEAN
DURING INSTEAD
USER_PROC_DEPENDS ANS)USER_DEPENDENCIES
A package A stored function
ANS)DROP TRIGGER business_hour; DELETE TRIGGER business_hour;
Use the
Use the DBMS_MANAGE_LOB.MIGRATE UTL_MANAGE_LOB.MIGRATE
procedure. procedure
The view associated with the trigger The table associated with the trigger
CALC_TAX INSERT_EMP
The trigger records an audit trail The trigger marks the user as logged on
when a user makes changes to the to the database before an audit
database. statement is issued.
OPEN emp_cursor. OPEN emp_cursor('clerk',10);
Row level DML trigger ANS)Row level application trigger
ANS)Synonyms Index
CREATE OR REPLACE PROCEDURE ANS)CREATE OR REPLACE
tax_amt FUNCTION tax_amt
(p_id NUMBER) (p_id NUMBER)
RETURN NUMBER RETURN NUMBER
ANS)Row Statement
ANS)If you remove the package If you remove the package body, then
specification, then the package body and the the package specification and the stand
stand alone stored function CALC_HEIGHT alone stored function CALC_HEIGHT
are removed. are removed
A conditional predicate means you use
A conditional predicate allows you to the NEW and
specify a WHEN-LOGGING-ON condition in OLD qualifiers in the trigger body as a
the trigger body. condition.
Heading. ANS)Executable
USER_OBJECTS. ANS)ALL_OBJECTS.
SELECT last_name,salary
SELECT last_name,salary FROM employee;
FROM employee; WHERE id=3;
DECLARE
ANS)DECLARE CURSOR emp-cursor 1S
CURSOR emp-cursor 1S SELECT ename,dept no
SELECT ename,dept no FROM emp;
FROM emp; BEGIN
BEGIN FOR emp-rec IN emp-cursor LOOP
FOR emp-rec IN emp-cursor LOOP OPEN emp-cursor;
INSERT INTO temp-emp(name,dno) INSERT INTO temp-emp(name,dno)
VALUES (emp-rec.ename, VALUES (emp-rec.ename,
emp-re.deptno); emp_rec.deptno);
END LOOP END LOOP
END; END;
MY_VIEWS. ANS)USER_VIEWS.
0 ANS)1
BINARY_INTEGER SIGNTYPE
ANS)VALUE_ERROR SUBSCRIPT_BEYOND_COUNT.
VALUE_ERROR ANS)SUBSCRIPT_BEYOND_COUNT.
VALUE_ERROR SUBSCRIPT_BEYOND_COUNT.
Exists Trim
EXTEND TRIM
EXTEND EXISTS
ANS)Exists Extend
Extend(n) ANS)Exists(n)
Count Exists
Extends(n) ANS)Prior(n)
ANS)1 .. 2**31 1 .. size_limit
1 .. 2**31 ANS)1 .. size_limit
Count Limit
Count Limit
0 ANS)Null
Extends(n) Prior(n)
ANS)TRIM TRIM(n)
TRIM ANS)TRIM(n)
TRIM TRIM(n)
TRIM TRIM(n)
OPTION C OPTION D OPTION E
3 ANS)4
Set SESSION_OPEN_CURSORS
Set SESSION_CURSORS parameter parameter in the initialization
in initialization Parameter parameter
65535 0
ANS)2,3 1,2,5
Permanent Tablespace
Packages collections
collections Recordset
ANS)Option 1,3
ANS)Option 1,2
SQLMSG ANS)SQLERRM
%DATATYPE %ROWCOUNT
After commit statements all changes
will be stored permanently in the
database. ANS)all of these
A trigger constraint ANS)Option 1,2,3
UPDATE ANS)none of these
Raise_application_error TOO_MANY_ROWS
ANS)Raise_application_error TOO_MANY_ROWS
Both procedure and functions are Both procedure and functions are
called a apart of the expression called as plsql statement
TO_CHAR(sal,'WORDS') TO_DATE(TO_CHAR(sal,'JSP'),'j')
ANS)12 50
A SELECT statement
COUNT MAX
PROCEDURE <name> AS
BEGIN
ans) B & C
<program code>
END
FUNCTION <name> AS RETURN FUNCTION <name> RETURN
<datatype> <datatype> AS
DECLARE DECLARE
BEGIN BEGIN
<program code> <program code>
END END
OUT variable of NUMBER type is
Declaure an input variable as INOUT
allowed
PACKAGE ans) B&C
SUBSTR A&D
RANDOM RUNTIME
4000 No limit
VARCHAR2 TYPE
TRIGGER TABLE
LEFT RIGHT
Legal because it can reference any Legal because %type is new data
table and column type type available in higher versions
use "utl_file"
A,D,E D,E
In Char type spaces will be padded
Both the cases the space will be after 'name' uptp max length 20.in
padded after 'name' upto max length Varchar spaces will padded before
20 'name' upto max length 20
After AS keyword we specify the
return datatype. After IS
Using AS will throw error while keyword we do the variable
compilation declaration
INVALID_CURSOR ANS)Option1,2
3,4,1,2 2,1,4,3
No action is performed
DBMS_OUTPUT.PUT_LINE
ANS)DBMS_OUTPUT.PUT_LINE (dept(dept_rec.dname); Simple
750 1000 Simple
DECLARE ANS)DECLARE
TYPE emp-table is TABLE of emp TYPE emp-table-type is TABLE of
%ROWTYPE emp%ROWTYPE
INDEX BY WHOLE NUMBER; INDEX BY BINARY INTEGER;
emp-table emp-table-type; emp-table emp-table-type; Simple
A cursor for each active set. ANS)A cursor that uses parameters. Simple
1 NULL Simple
The data type in the select list are
inconsistent with the data types in
the into clause. ANS)Both A &B Simple
DECLARE
ANS)DECLARE v-hiredate DATE:=SYSDATE:
v-hiredate DATE:=SYSDATE: BEGIN
BEGIN INSERT INTO
INSERT INTO emp(empnp,ename,heridate,deptno)
emp(empnp,ename,hiredate) VALUES(empno_sequence.nextval,
VALUES(empno_sequence.nextval, 'and name',v_hitedate and deptno)
name, v_hiredate) Job=Clerk
END: END: Medium
6 ANS)8 Medium
UPDATE emp
ANS)UPDATE emp SET values job = 'Administrative
SET job = 'Administrative Clerk' Clerk'
WHERE UPPER (job) = 'CLERK'; WHERE UPPER (job) = 'Clerk'; Simple
It does not persist across It persists from user to user when the
transaction within a session. package is invoked. Medium
ANS)The value of
The value of DISCOUNT_RATE is DISCOUNT_RATE is set to 0.10
set to 1.00 each time the procedure when the package is invoked for the
DISPLAY_PRICE is invoked. first time in a session Complex
A value equal to the number of rows
NONE in the EMP table. Complex
The package specification is optional, Both the specification and body are
but the package body is required. required components of a package Medium
You use a system event trigger to fire You use INSTEAD OF trigger to fire
when an UPDATE statement occurs. when a SELECT statement occurs. Simple
ANS)OUT IN Simple
Use the
DBMS_LOB.MIGRATE ANS)Use the ALTER TABLE
procedure command. Medium
ANS)EXECUTE
INSERT_TEAM(3,
'AUSTIN','LONGHORNS'); BOTH B AND C Medium
The executable section of a stored
procedure contains statements that
assigns values, control execution,and
return values to the calling A stored procedure is typically
environment. written in SQL. Simple
EXECUTE add_dept
EXECUTE add_dept('2500', p_loc =>2(p_name=>'Education', 2500) Medium
EXECUTE UPD_BAT_STAT(V_AB=>10,
ANS)BOTH AND C Simple
ANS)The trigger fails because a The trigger fails because you cannot
SELECT use the minimum and
statement on the table being updated maximum functions in a BEFORE
is not allowed. UPDATE trigger Medium
ANS)Last name and first name of all Last name and first name of only the
the employees employees whose salary falls in the
with the same salary as employee in range of salary from
the department 3 and 5. department 3 or 5. Medium
ANS)Equal operators. Between x and y operator. Simple
ANS)Test for the rows using the
Initialize the loop. cursor attribute. Simple
SELECT*
INTO
dept_rec.dno,dept_rec.name,dept_re
ANS)You can't retrieve the entire row c.
using the DEPT_REC variable FROM dept
declared in the code. WHERE dept no=10; Medium
DECLARE
DECLARE CURSOR emp-cursor 1S
CURSOR emp-cursor 1S SELECT ename,dept no
SELECT ename,dept no FROM emp;
FROM emp; emp-rec emp-cursor%ROWTYPE;
BEGIN BEGIN
FOR emp-rec IN emp-cursor LOOP FETCH emp-cursor
OPEN emp-cursor; INTO emp-rec;
INSERT INTO temp-emp(name,dno) FOR emp-recIN emp-cursor LOOP
VALUES (emp-rec.ename, INSERT INTO temp-emp(name,dno)
emp-rec.deptno); VALUES (emp-rec.ename,
END LOOP emp-rec.deptno);
CLOSE emp-cursor; END LOOP
END; END; Simple
When an update statement in a
ANS)When a select statement in a PL/SQL block has to modify more
PL/SQL block is more than one row. than one row. Simple
1 None Medium
Medium
Difficult
Difficult
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Difficult
Difficult
Difficult
Difficult
Medium
Difficult
Difficult
Difficult
Simple
Difficult
Difficult
Difficult
Medium
Medium
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Complex
Difficult
Medium
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Medium
Medium
Medium
Difficult
Medium
Medium
Medium
Medium
Medium
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Medium
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Difficult
Complex
Complex
Complex
Medium
Medium
Medium
Medium
Medium
Medium
difficult
difficult
Difficult
QUESTION # QUESTIONS
10
11
12
13
14
15
Option A Option B Option C Option D Option E
Solution
QUESTION # QUESTIONS Option A Option B Option C Option D Option E Solution
QUESTION
QUESTIONS
# Option A Option B Option C Option D Option E Solution
QUESTION
QUESTIONS
# Option A Option B Option C Option D Option E Solution