Ans 1

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

1.

Read the following code: CREATE OR REPLACE PROCEDURE find_cpt (v_movie_id {Argument Mode} NUMBER, v_cost_per_ticket {argument mode} NUMBER) IS BEGIN IF v_cost_per_ticket > 8.5 THEN SELECT cost_per_ticket INTO v_cost_per_ticket FROM gross_receipt WHERE movie_id = v_movie_id; END IF; END; Which mode should be used for V_COST_PER_TICKET? 1 IN 2 OUT 3 RETURN 4 IN OUT Ans INOUT mode
2.How can you find within a PL/SQL block, if a cursor is open?

Ans-%ISopen is used ..when cursor is open .. 3.What are SQLCODE and SQLERRM and why are they important for PL/SQL developers? Ans----SQLCODE returns the value of the error number for the last error encountered. The SQLERRM returns the actual error message for the last error encountered. They can be used in exception handling to report, or, store in an error log table, the error that occurred in the code. These are especially useful for the WHEN OTHERS exception. 4.When is a declare statement needed ? DECLARE stmt is defines a variable This section is optional. Used to declare variables,cursors,constants

5. Describe the use of %ROWTYPE and %TYPE in PL/SQL Ans both are used to define variables. Table name & column name must already exist in database %TYPE and %ROWTYPE constructs provide data independence, reduces maintenance costs, and allows programs to adapt as the database changes to meet new business needs. %TYPE is used to declare a field with the same type as that of a specified table's column %ROWTYPE is used to declare a record with the same types as found in the specified database table, view or cursor %ROWTYPE allows you to associate a variable with an--- entire table row. %TYPE associates a variable with ----a single column type. 6. What packages (if any) has Oracle provided for use by developers? ans--Oracle provides the DBMS_ series of packages. There are many which developers should be aware of such as DBMS_SQL, DBMS_PIPE, DBMS_TRANSACTION, DBMS_LOCK, DBMS_ALERT, DBMS_OUTPUT, DBMS_JOB, DBMS_UTILITY, DBMS_DDL, UTL_FILE. 7. How can you generate debugging output from PL/SQL? Ans-DBMS_OUTPUT 8. What is a mutating table error and how can you get around it? Ans---This happens with triggers. It occurs because the trigger is trying to update a row which is currently used. The usual fix involves either use of views or temporary tables so the database is selecting from one while updating the other.

ORA-39116: invalid trigger operation on mutating table string.string Cause: A Data Pump load operation failed because a trigger attempted to fire on the table while it was mutating. Action: Disable trigger(s) on the specified table 9.Describe the difference between a procedure, function and anonymous pl/sql block Ans Functions- must returns a value Procedure doesn t retunrs a value. An anonymous block:- is a PL/SQL program unit that has no name. An anonymous block consists of 1)an optional declarative part, 2)an executable part, and 3)one or more optional exception handlers. The declarative part declares PL/SQL 1)variables, 2)exceptions and 3)cursors. The executable part contains PL/SQL code and SQL statements, and can contain nested blocks. Exception handlers contain code that is called when the exception is raised, either as a predefined PL/SQL exception (such as NO_DATA_FOUND or ZERO_DIVIDE) or as an exception that you define.

1. Examine this code BEGIN theater_pck.v_total_seats_sold_overall := theater_pck.get_total_for_year; END; For this code to be successful, what must be true? 1 Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the GET_TOTAL_FOR_YEAR function must exist only in the body of the THEATER_PCK package.

Only the GET_TOTAL_FOR_YEAR variable must exist in the specification of the THEATER_PCK package. 3 Only the V_TOTAL_SEATS_SOLD_OVERALL variable must exist in the specification of the THEATER_PCK package. 1.Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the GET_TOTAL_FOR_YEAR function must exist in the specification of the THEATER_PCK package

You might also like