PL/SQL Interview Questions Flashcards

1
Q

What is PL/SQL

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Difference between %ROWTYPE and TYPE Record

A

%ROWTYPE is used when a query returns an entire row of a table or view.

TYPE RECORD is used when a query returns column or different tables or views

TYPE r_emp is RECORD (sno smp.smpno%type, snake smp sname %TYPE)

e_rec smp %ROWTYPE

Cursor c1 is select smpno,dept from smp;

e_rec c1 %ROWTYPE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Explain use of a cursor

A

Cursor is a named private area in SQL from which information can be accessed. When multiple records exist they require is record to be processed individually

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Cursor code example for loop

A

FOR smp_rec IN C1 LOOP
Totalsal:=totalsal + 100;
ENDLOOP;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Explain the use of Database Triggers

A

A PL/SQL program unit associated with a particular DB table. It is used for:

  1. Audit data modifications
  2. Log events transparently
  3. Enforce complex business rules
  4. maintain Replica Tables
  5. Derive column values
  6. Implement Complex security authorizations
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are two types of Exceptions

A

Error handle part of PL/SQL Block

  1. user_defined
  2. Predefined
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Show some predefined exceptions

A

DUP_VL_ON_INDEX

ZERO_DIVIDE

NO_DATA_FOUND

TOO_MANY_ROWS

CURSOR_ALREADY _OPEN

INVALID_NUMBER

INVALID_CURSOR

PROGRAM_ERROR

TIMEOUT_ON_RESOURCE

STORAGE_ERROR

LOGON_DENIED

VALUE_ERROR
etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Explain Raise_application_error

A

It is a procedure of package DBMS_STANDARD that allows issuing of user_defined error messages from DB trigger or stored sub-program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly