You are on page 1of 3

5 What will happen after commit statement ?

Cursor C1 is
Select empno,
ename from emp;
Begin
open C1; loop
Fetch C1 into
eno.ename;
Exit When
C1 %notfound;-----
commit;
end loop;
end;

The cursor having query as SELECT .... FOR UPDATE gets closed after COMMIT/ROLLBACK.

The cursor having query as SELECT.... does not get closed even after COMMIT/ROLLBACK.

6 What is the basic structure of PL/SQL ?

PL/SQL uses block structure as its basic structure. Anonymous blocks or nested blocks can be used in
PL/SQL.

7 What is Raise_application_error ?

Raise_application_error is a procedure of package DBMS_STANDARD which allows to issue an
user_defined error messages from stored sub-program or database trigger.

8 What is Pragma EXECPTION_INIT ? Explain the usage ?

The PRAGMA EXECPTION_INIT tells the complier to associate an exception with an oracle error. To
get an error message of a specific oracle error.

e.g. PRAGMA EXCEPTION_INIT (exception name, oracle error number)

9 What is PL/SQL table ?

Objects of type TABLE are called "PL/SQL tables", which are modeled as (but not the same as)
database tables, PL/SQL tables use a primary PL/SQL tables can have one column and a primary key.

Cursors

10 What is Overloading of procedures ?

The Same procedure name is repeated with parameters of different datatypes and parameters in
different positions, varying number of parameters is called overloading of procedures.

A PROCEDURE may return one or more values through parameters or may not return at all.empno% type. TYPE r_emp is RECORD (eno emp.e. The types are Predefined and user defined. TYPE rec RECORD is to be used whenever query returns columns of different table or views and variables. e_rec c1 %ROWTYPE. e_rec emp% ROWTYPE cursor c1 is select empno. 12 What is difference between a Cursor declared in a procedure and Cursor declared in a package specification ? A cursor declared in a package specification is global and can be accessed by other procedures or procedures in a package. CURSOR_ALREADY_OPEN DUP_VAL_ON_INDEX NO_DATA_FOUND TOO_MANY_ROWS INVALID_CURSOR INVALID_NUMBER LOGON_DENIED NOT_LOGGED_ON PROGRAM-ERROR STORAGE_ERROR TIMEOUT_ON_RESOURCE VALUE_ERROR ZERO_DIVIDE . Some of Predefined exceptions are. A cursor declared in a procedure is local to the procedure that can not be accessed by other procedures. DBMS_OUTPUT put_line What is a package ? What are the advantages of packages ? 11 What is difference between a PROCEDURE & FUNCTION ? A FUNCTION is always returns a value using the return statement. 14 What is an Exception ? What are types of Exception ? Exception is the error handling part of PL/SQL block.g.deptno from emp.g. 13 What is difference between % ROWTYPE and TYPE RECORD ? % ROWTYPE is to be used whenever query returns a entire row of a table or view.ename emp ename %type ). E.

Cursors are required to process rows individually for queries returning multiple rows.column_name NEW. FOR emp_rec IN C1 LOOP salary_total := salary_total +emp_rec sal.column_name values only available. For triggers related to INSERT only NEW.OTHERS. Maintain replicate tables. Enforce complex business rules Derive column values automatically. Usages are Audit data modifications. For triggers related to DELETE only OLD. .column_name.column_name values only available. Implement complex security authorizations. eg. 15 What is a stored procedure ? A stored procedure is a sequence of statements that perform specific function.column_name and NEW.opens a cursor. 19 What happens if a procedure that updates a column of table X is called in a database trigger of the same table ? Mutation of table occurs.column_name values only available. fetches rows of values from active set into fields in the record and closes when all the records have been processed. 17 What is a cursor for loop ? Cursor for loop implicitly declares %ROWTYPE as loop index. For triggers related to UPDATE only OLD. 18 What is a cursor ? Why Cursor is required ? Cursor is a named private SQL area from where information can be accessed. END LOOP. 20 What are two virtual tables available during database trigger execution ? The table columns are referred as OLD. 16 What is a database trigger ? Name some usages of database trigger ? Database trigger is stored PL/SQL program unit associated with a specific database table. Log events transparently.