Вы находитесь на странице: 1из 6

1. What is PL/SQL ?

PL/SQL is a procedural language which has interactive SQL, as well as procedural programming
language constructs like conditional branching and iteration.

2. Differentiate between % ROWTYPE and TYPE RECORD.
% ROWTYPE is used when a query returns an entire row of a table or view.
TYPE RECORD on the other hand, is used when a query returns column of different tables or
views.
g. !"P r#emp is RECORD $sno smp.smpno%type,sname smp sname %type&
e#rec smp ROWTYPE
'ursor c( is select smpno,dept from smp)
e#rec c( %ROWTYPE

!. E"#$ain %ses &f '%rs&r.
'ursor is a named private area in SQL from which information can be accessed. !hey are
required to process each row individually for queries which return multiple rows.

(. Sh&w '&de &f a '%rs&r f&r $&&#.
'ursor declares %*+,!"P as loop inde- implicitly. .t then opens a cursor, gets rows of
values from the active set in fields of the record and shuts when all records are processed.
g. /+* smp#rec .0 '( L++P
totalsal1totalsal2smp#recsal)
03L++P)

). E"#$ain the %ses &f database tri**er.
4 PL/SQL program unit associated with a particular database table is called a database trigger. .t
is used for 5
(&4udit data modifications.
6&Log events transparently.
7&nforce comple- business rules.
8&9aintain replica tables
:&3erive column values
;&.mplement 'omple- security authori<ations

+. What are the tw& t,#es &f e"'e#ti&ns.
rror handling part of PL/SQL block is called -ception. !hey have two types 5 user#defined
and predefined.

-. Sh&w s&.e #redefined e"'e#ti&ns.
3=P#>4L#+0#.03?
@*+#3.>.3
0+#34!4#/+=03
!++#940"#*+,S
'=*S+*#4L*43"#+P0
.0>4L.3#0=9A*
.0>4L.3#'=*S+*
P*+B*49#**+*
!.9+=! #+0#*S+=*'
S!+*4B#**+*
L+B+0#30.3
>4L=#**+*
etc.

/. E"#$ain Raise0a##$i'ati&n0err&r.
.t is a procedure of package 3A9S#S!4034*3 that allows issuing of user#defined error
messages from database trigger or stored subCprogram.

1.Sh&w h&w f%n'ti&ns and #r&'ed%res are 'a$$ed in a PL/SQL b$&'2.
/unction is called as a part of an e-pression.
total51calculate#sal$Db;88E&
Procedure is called as a statement in PL/SQL.
calculate#bonus$Db;88E&)

13. E"#$ain tw& 4irt%a$ tab$es a4ai$ab$e at the ti.e &f database tri**er e"e'%ti&n.
!able columns are referred as !F0.column#name and 0+,.column#name.
/or .0S*! related triggers, 0+,.column#name values are available only.
/or 3L! related triggers, !F0.column#name values are available only.
/or =P34! related triggers, both !able columns are available.

11. What are the r%$es t& be a##$ied t& 56LLs whi$st d&in* '&.#aris&ns?
(& 0=LL is never !*= or /4LS
6& 0=LL cannot be equal or unequal to other values
7& .f a value in an e-pression is 0=LL, then the e-pression itself evaluates to 0=LL e-cept for
concatenation operator $GG&

12. 7&w is a #r&'ess &f PL/SQL '&.#i$ed?
'ompilation process includes synta- check, bind and pCcode generation processes.
Synta- checking checks the PL/SQL codes for compilation errors. ,hen all errors are corrected,
a storage address is assigned to the variables that hold data. .t is called Ainding. PCcode is a list
of instructions for the PL/SQL engine. PCcode is stored in the database for named blocks and is
used the ne-t time it is e-ecuted.

1!. Differentiate between S,nta" and r%nti.e err&rs.
4 synta- error can be easily detected by a PL/SQL compiler. /or eg, incorrect spelling.
4 runtime error is handled with the help of e-ceptionChandling section in an PL/SQL block. /or
eg, SL'! .0!+ statement, which does not return any rows.

1(. E"#$ain C&..it R&$$ba'2 and Sa4e#&int.
/or a '+99.! statement, the following is true5
+ther users can see the data changes made by the transaction.
!he locks acquired by the transaction are released.
!he work done by the transaction becomes permanent.
4 *+LLA4'H statement gets issued when the transaction ends, and the following is true.
!he work done in a transition is undone as if it was never issued.
4ll locks acquired by transaction are released.
.t undoes all the work done by the user in a transaction. ,ith S4>P+.0!, only part of
transaction can be undone.

1). Define 8.#$i'it and E"#$i'it C%rs&rs.
4 cursor is implicit by default. !he user cannot control or process the information in this cursor.
.f a query returns multiple rows of data, the program defines an e-plicit cursor. !his allows the
application to process each row sequentially as the cursor returns it.

1+. E"#$ain .%tatin* tab$e err&r.
.t occurs when a trigger tries to update a row that it is currently using. .t is fi-ed by using views
or temporary tables, so database selects one and updates the other.

1-. When is a de'$are state.ent re9%ired?
3'L4* statement is used by PL/SQL anonymous blocks such as with stand alone, nonCstored
procedures. .f it is used, it must come first in a stand alone file.

1/. 7&w .an, tri**ers 'an be a##$ied t& a tab$e?
4 ma-imum of (6 triggers can be applied to one table.

11. What is the i.#&rtan'e &f SQLCODE and SQLERR:?
SQL'+3 returns the value of the number of error for the last encountered error whereas
SQL**9 returns the message for the last error.

23. 8f a '%rs&r is &#en h&w 'an we find in a PL/SQL ;$&'2?
the %.S+P0 cursor status variable can be used.

21. Sh&w the tw& PL/SQL '%rs&r e"'e#ti&ns.
'ursor#4lready#+pen
.nvaid#cursor

22. What &#erat&rs dea$ with 56LL?
0>L converts 0=LL to another specified value.
var510>L$var6,EFiE&)
.S 0=LL and .S 0+! 0=LL can be used to check specifically to see whether the value of a
variable is 0=LL or not.

2!. D&es SQL<P$%s a$s& ha4e a PL/SQL En*ine?
0o, SQLIPlus does not have a PL/SQL ngine embedded in it. !hus, all PL/SQL code is sent
directly to database engine. .t is much more efficient as each statement is not individually
stripped off.

2(. What #a'2a*es are a4ai$ab$e t& PL/SQL de4e$&#ers?
3A9S# series of packages, such as, 3A9S#P.P, 3A9S#33L, 3A9S#L+'H,
3A9S#4L*!, 3A9S#+=!P=!, 3A9S#J+A, 3A9S#=!.L.!", 3A9S#SQL,
3A9S#!*40S4'!.+0, =!L#/.L.

2). E"#$ain ! basi' #arts &f a tri**er.
4 triggering statement or event.
4 restriction
4n action

Вам также может понравиться