What is a package spec and package body? Why the separation? |
Spec declares public constructs. Body defines public constructs, additionally declares and defines Private constructs. |
What is the difference between anonymous blocks and stored procedures? |
Anonymous block is PL/SQL code and compiled only when called. |
Can you use COMMIT in a trigger? |
Yes but by defining an autonomous transaction. |
What is an autonomous transaction? |
An autonomous transaction is an independent transaction that is initiated by another transaction (the parent transaction). An autonomous transaction can modify data and commit or rollback independent of the state of the parent transaction. |
What is the difference between implicit and explicit cursors? |
An explicit cursor is declared opened and fetched from in the program block where as an implicit cursor is automatically generated for SQL statements. |
What are the cursor attributes used in PL/SQL? |
% ISOPEN – Used to check whether a cursor is open or not. |
What are % TYPE and % ROWTYPE? What are the advantages of using these over datatypes? |
% TYPE provides the data type of a variable or a database column to that variable. |
What are the datatypes a available in PL/SQL? |
Some scalar data types such as NUMBER, VARCHAR2, DATE, CHAR, LONG, BOOLEAN. Some composite data types such as RECORD & TABLE. |
What are the components of a PL/SQL Block? |
Declarative part |
What is a stored procedure ? |
A stored procedure is a sequence of statements that perform specific task. A stored procedure is a named pl/sql block which performs an action.It is stored in the database as a schema object and can be repeatedly executed.It can be invoked, parameterised and nested. |
What is a cursor ? Why Cursor is required? |
Cursor is a named private SQL area from where information can be accessed. Cursors are required to process rows individually for queries returning multiple rows. |
What are advantages of Stored Procedures? |
Extensibility,Modularity, Reusability, Maintainability and one time compilation. |
How can a function retun more than one value in oracle with proper example? |
Basically as per property of function it has to return one value. So the other values can be returned from the out parameter of the function. But its advised if you want more that one return value go for procedure however function will also yield the same result. |
What is a cursor for loop ? |
Cursor for loop implicitly declares %ROWTYPE as loop index,opens a cursor, fetches rows of values from active set into fields in the record and closes when all the records have been processed. FOR emp_rec IN C1 LOOP salary_total := salary_total +emp_rec sal; END LOOP; |
Is it possible to use Transaction control Statements such a ROLLBACK or COMMIT in Database Trigger? Why? |
It is not possible. As triggers are defined for each table, if you use COMMIT of ROLLBACK in a trigger, it affects logical transaction processing. yes WE can use COMMIT and ROLLBACK triggers, but by using PRAGAMA AUTONAMOUS_TRANSATIONS. Now the transation treated as a autonomous tansation. |
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. Usages are Audit data modifications, Log events transparently, Enforce complex business rules Derive column values automatically, Implement complex security authorizations. Maintain replicate tables. |