PAPER: ORACLE PLACEMENT PAPER (TECHNICAL-DATABASE)
1. What are the PL/SQL Statements used in cursor processing ?
ANS:-DECLARE CURSOR cursor name, OPEN cursor name, FETCH cursor name INTO or Record types, CLOSE cursor name.
2. What are the cursor attributes used in PL/SQL ?
ANS:-%ISOPEN - to check whether cursor is open or not
% ROWCOUNT - number of rows fetched/updated/deleted.
% FOUND - to check whether cursor has fetched any row. True if rows are fetched.
% NOT FOUND - to check whether cursor has fetched any row. True if no rows are fetched.
These attributes are proceeded with SQL for Implicit Cursors and with Cursor name for Explicit Cursors.
3. What is a cursor for loop ?
ANS:-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.
eg. FOR emp_rec IN C1 LOOP
salary_total := salary_total +emp_rec sal;
END LOOP ;
4. What will happen after commit statement ?
ANS:-Cursor C1 is
ename from emp;
open C1; loop
Fetch C1 into
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.
5. Explain the usage of WHERE CURRENT OF clause in cursors ?
ANS:-WHERE CURRENT OF clause in an UPDATE, DELETE statement refers to the latest row fetched from a cursor.
6. What is a database trigger ? Name some usages of database trigger ?
ANS:- 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.
7. How many types of database triggers can be specified on a table ? What are they ?
ANS:-Insert Update Delete
Before Row, After Row , Before Statement , After Statement
If FOR EACH ROW clause is specified, then the trigger for each Row affected by the statement. If WHEN clause is specified, the trigger fires according to the returned Boolean value.
8. Is it possible to use Transaction control Statements such a ROLLBACK or COMMIT in Database Trigger ? Why ?
ANS:-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.
9. What are two virtual tables available during database trigger execution ?
ANS:-The table columns are referred as OLD.column_name and NEW.column_name.
For triggers related to INSERT only NEW.column_name values only available.
For triggers related to UPDATE only OLD.column_name NEW.column_name values only available.
For triggers related to DELETE only OLD.column_name values only available.
10. What happens if a procedure that updates a column of table X is called in a database trigger of the same table ?
ANS:-Mutation of table occurs.
11. Write the order of precedence for validation of a column in a table ?
I. done using Database triggers.
ii. done using Integrity Constraints.
12. What is an Exception ? What are types of Exception ?
ANS:-Exception is the error handling part of PL/SQL block. The types are Predefined and user defined. Some of Predefined exceptions are.
13. What is Pragma EXECPTION_INIT ? Explain the usage ?
ANS:-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)
14. What is Raise_application_error ?
ANS:-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.
15. What are the return values of functions SQLCODE and SQLERRM ?
ANS:-SQLCODE returns the latest code of the error that has occurred. SQLERRM returns the relevant error message of the SQLCODE.
16. Where the Pre_defined_exceptions are stored ? In the standard package?
ANS:-Procedures, Functions & Packages ;
17. What is a stored procedure ?
ANS:-A stored procedure is a sequence of statements that perform specific function.
18. What is difference between a PROCEDURE & FUNCTION ?
ANS:-A FUNCTION is always returns a value using the return statement. A PROCEDURE has no return type.
19. What are advantages for Stored Procedures ?
ANS:-Extensibility, Modularity, Reusability, Maintainability and one time compilation.
20. What are the modes of parameters that can be passed to a procedure ?
ANS:- IN,OUT,IN-OUT parameters.
21. What are the two parts of a procedure ?
ANS:- Procedure Specification and Procedure Body.
22. Give the structure of the procedure ?
ANS:-PROCEDURE name (parameter list.....) is local variable declarations
23. Give the structure of the function ?
ANS:-FUNCTION name (argument list .....) Return data type is local variable declarations
24. Explain how procedures and functions are called in a PL/SQL block ?
ANS:-Function is called as part of an expression. sal := calculate_Sal ('a822'); procedure is called as a PL/SQL statement calculate_bonus ('A822');
25. What is Overloading of procedures ?
ANS:-The Same procedure name is repeated with parameters of different data types and parameters in different positions, varying number of parameters is called overloading of procedures.
e.g. DBMS_OUTPUT put_line
26. What is a package ? What are the advantages of packages ?
ANS:-Package is a database object that groups logically related procedures. The advantages of packages are Modularity, Easier Application Design, Information. Hiding,. reusability and Better Performance.
27.What are two parts of package ?
ANS:-The two parts of package are PACKAGE SPECIFICATION & PACKAGE BODY. Package Specification contains declarations that are global to the packages and local to the schema. Package Body contains actual procedures and local declaration of the procedures and cursor declarations.
28. What is difference between a Cursor declared in a procedure and Cursor declared in a package specification ?
ANS:-A cursor declared in a package specification is global and can be accessed by other procedures or procedures in a package. A cursor declared in a procedure is local to the procedure that can not be accessed by other procedures.
29. How packaged procedures and functions are called from the following?
ANS:-a. Stored procedure or anonymous block
b. an application program such a PRC *C, PRO* COBOL
c. SQL *PLUS
a. PACKAGE NAME.PROCEDURE NAME (parameters);
variable := PACKAGE NAME.FUNCTION NAME (arguments);
EXEC SQL EXECUTE
PACKAGE NAME.PROCEDURE NAME (parameters)
variable := PACKAGE NAME.FUNCTION NAME (arguments);
c. EXECUTE PACKAGE NAME.PROCEDURE if the procedures does not have any
out/in-out parameters. A function can not be called.
30. Name the tables where characteristics of Package, procedure and functions are stored ?
ANS:-User_objects, User_Source and User_error.
31. what is a display item?
ANS:-Display items are similar to text items but store only fetched or assigned values. Operators cannot navigate to a display item or edit the value it contains.
32. What is a list item?
ANS:-It is a list of text elements.
33. What are the display styles of list items?
ANS:-Pop list, No text Item displayed in the list item. THE list, No element in the list is highlighted.
34. What is a radio Group?
ANS:-Radio groups display a fixed no of options that are mutually Exclusive . User can select one out of n number of options.
35. How many maximum number of radio buttons can you assign to a radio group?
ANS:-Unlimited no of radio buttons can be assigned to a radio group
36. can you change the default value of the radio button group at run time?
37.What triggers are associated with the radio group?
ANS:-Only when-radio-changed trigger associated with radio group