Oracle PL/SQL Programming
Covers PL/SQL stored procedures, functions, packages, triggers, exception handling, and cursors in Oracle databases
Questions
Implicit cursors are declared for
- Some DML,PL/SQL statements
- All DML,PL/SQL statements
- Only PL/SQL statements
- None of the Above
Which is the procedure used to issue User-Defined error messages from stored Sub-Programs?
- Raise Application procedure
- Raise Application Error procedure
- Application Error procedure
- None of the Above
How do you handle an Exception?
- Trap it with a Handler
- Propagate it to the Calling Environment
- a & then b
- b & then a
Examine this procedure: CREATE OR REPLACE PROCEDURE DELETE_PLAYER(V_IDIN NUMBER) IS BEGIN DELETE FROM PLAYER WHERE ID = V_ID EXCEPTION WHEN STATS_EXIST_EXCEPTION THEN DBMS_OUTPUT.PUT_LINE(Cannotdeletethisplayer, childrecordsexistin PLAYER_BAT_STAT table); END; What prevents this procedure from being created successfully?
- A comma has been left after the STATS_EXIST_EXCEPTION exception.
- The STATS_EXIST_EXCEPTION has not been declared as a number.
- The STATS_EXIST_EXCEPTION has not been declared as an exception.
- None
Under which two circumstances do you design database triggers? (Choose two)
- To duplicate the functionality of other triggers.
- To replicate built-in constraints in the Oracle server such as primary key and foreign key.
- To guarantee that when a specific operation is performed, related actions are performed.
- For centralized, global operations that should be fired for the triggering statement, regardless of which user or application issues the statement.
Which two statements about the overloading feature of packages are true? (Choose two)
- Only local or packaged sub programs can be overloaded.
- Overloading allows different functions with the same name that differ only in their return types.
- Overloading allows different subprograms with the same number, type and order of the parameter.
- Overloading allows different subprograms with the same name and same number or type of the parameters.
- Overloading allows different subprograms with the same name but different in either number or type or order of parameter.
What does “REPLACE” indicate in creating procedures?
- An existing will be dropped and it will be replaced by the new version.
- An existing will be dropped and it will not be replaced by the new version.
- No change will occur
- There is no such option available in creating procedures.
Which two statements about packages are true? (Choose two)
- Packages can be nested.
- You can pass parameters to packages.
- A package is loaded into memory each time it is invoked.
- The contents of packages can be shared by many applications.
- You can achieve information hiding by making package constructs private.
A function must return zero or more values to its calling environment, whereas a procedure returns a value to the calling environment.
- True
- False
Which of the following statements is false with respect to packages?
- The package itself cannot be called, parameterized, or nested.
- The format of a package is similar to that of a subprogram.
- The contents can be shared by many applications once written.
- None of the above.
Identifiers defined only in the package body are public constructs. These are visible outside the package body
- True
- False
Private constructs in the package body are hidden and inaccessible.This is an advantage of a package
- True
- False
This statement fails when executed: CREATE OR REPLACE TRI GGER CALC_TEAM_AVG AFTER I NSERT ON PLAYER BEGIN INSERT INTO PLAYER_BATSTAT ( PLAYER_I D, SEASON_YEAR, AT_BATS, HI TS) VALUES ( : NEW. I D, 1 997, 0, 0) ; END; To which type must you convert the trigger to correct the error?
- Row
- Statement
- ORACLE FORM trigger
- Before
Which two program declarations are correct for a stored program unit? (Choose two)
- CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER
- CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER) RETURN NUMBER
- CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER)
- CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER(10,2)
- CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER(10, 2))
What is true about stored procedures?
- A stored procedure uses the DELCLARE keyword in the procedure specification to declare formal parameters.
- A stored procedure is named PL/SQL block with at least one parameter declaration in the procedure specification.
- A stored procedure must have at least one executable statement in the procedure body.
- A stored procedure uses the DECLARE keyword in the procedure body to declare formal parameters.
Examine this procedure: CREATE OR REPLACE PROCEDURE UPD_BAT_STAT (V_ID IN NUMBER DEFAULT 10, V_AB IN NUMBER DEFAULT 4) IS BEGIN UPDATE PLAYER_BAT_STAT SET AT_BATS = AT_BATS + V_AB WHERE PLAYER_ID = V_ID; COMMIT; END; Which two statements will successfully invoke this procedure in SQL *Plus? (Choose two)
- EXECUTE UPD_BAT_STAT;
- EXECUTE UPD_BAT_STAT(V_AB=>10, V_ID=>31);
- EXECUTE UPD_BAT_STAT(31, 'FOUR', 'TWO');
- UPD_BAT_STAT(V_AB=>10, V_ID=>31);
- RUN UPD_BAT_STAT;
Examine this code: CREATE OR REPLACE FUNCTION gen_email_name (p_first_name VARCHAR2, p_last_name VARCHAR2, p_id NUMBER) RETURN VARCHAR2 IS v_email_name VARCHAR2(19); BEGIN v_email_name := SUBSTR(p_first_name, 1, 1) || SUBSTR(p_last_name, 1, 7) || [email protected] .; UPDATE employees SET email = v_email_name WHERE employee_id = p_id; RETURN v_email_name; END; Examine this code: CREATE OR REPLACE PACKAGE comm_package IS g_comm NUMBER := 10; PROCEDURE reset_comm(p_comm IN NUMBER); END comm_package; / User Jones executes the following code at 9:01am: EXECUTE comm_package.g_comm := 15 User Smith executes the following code at 9:05am: EXECUTE comm_paclage.g_comm := 20 Which statement is true?
- g_comm has a value of 15 at 9:06am for Smith.
- g_comm has a value of 15 at 9:06am for Jones.
- g_comm has a value of 20 at 9:06am for both Jones and Smith.
- g_comm has a value of 15 at 9:03 am for both Jones and Smith.
- g_comm has a value of 10 at 9:06am for both Jones and Smith.
- g_comm has a value of 10 at 9:03am for both Jones and Smith.
Which three are valid ways to minimize dependency failure? (Choose three)
- Querying with the SELECT * notification.
- Declaring variables with the %TYPE attribute.
- Specifying schema names when referencing objects.
- Declaring records by using the %ROWTYPE attribute.
- Specifying package.procedure notation while executing procedures.
Which two describe a stored procedure? (Choose two)
- A stored procedure is typically written in SQL.
- A stored procedure is a named PL/SQL block that can accept parameters.
- A stored procedure is a type of PL/SQL subprogram that performs an action.
- A stored procedure has three parts: the specification, the body, and the exception handler part.
- The executable section of a stored procedure contains statements that assigns values, control execution, and return values to the calling environment.
A CALL statement inside the trigger body enables you to call ______.
- A package.
- A stored function.
- A stored procedure.
- Another database trigger.