NiC IT Academy

PLSQL Quiz – 07

By Mr.Chandra

Loading

1) You have a PL/SQL block that needs to handle different exceptions, including specific exceptions like NO_DATA_FOUND and TOO_MANY_ROWS. What is the correct order to handle these in an EXCEPTION block?

2) Which of the following is NOT a valid usage of the FORALL statement in PL/SQL?

3) What is the main advantage of using a package in PL/SQL?

4) Consider the following cursor: sql Copy code CURSOR c_emp IS SELECT employee_id, department_id FROM employees WHERE department_id = 50 FOR UPDATE NOWAIT; What will happen if another session tries to update the same row locked by this cursor?

5) What is the output of the following PL/SQL block? sql Copy code DECLARE v_sal NUMBER := 5000; BEGIN IF v_sal BETWEEN 3000 AND 6000 THEN v_sal := v_sal + 1000; ELSE v_sal := v_sal - 1000; END IF; DBMS_OUTPUT.PUT_LINE(v_sal); END;

6) You want to declare a PL/SQL collection to store multiple records from a table. Which of the following is the best choice?

7) Given the following PL/SQL code: sql Copy code DECLARE v_num NUMBER := 10; BEGIN LOOP EXIT WHEN v_num = 0; v_num := v_num - 1; END LOOP; DBMS_OUTPUT.PUT_LINE('Loop ended with v_num = ' || v_num); END; What is the output of the above block?

8) Which of the following statements about PL/SQL triggers is correct?

9) What is the purpose of the RAISE_APPLICATION_ERROR procedure in PL/SQL?

10) Given the table products with columns product_id, product_name, and quantity, you want to update the quantity to 0 if it is negative using a PL/SQL block. Which statement is best suited for this scenario?

11) You are tasked with creating a stored procedure to archive data from the orders table to the orders_archive table every month. The archive process involves moving completed orders. Which PL/SQL block is best suited for this task?

12) In a data migration project, you need to validate if all customer records in a source table have corresponding records in the destination table after migration. Which PL/SQL query would best check this condition?

13) Your project requires creating a trigger that automatically updates the last_updated_date field in the employees table whenever a record is updated. What kind of trigger is best suited for this?

14) You are building a financial report that needs to aggregate large volumes of transactional data. To improve performance, you decide to implement a PL/SQL block using bulk operations. Which technique would you use?

15) During an ETL process, you need to ensure that only unique customer records are inserted into the customers table. If a duplicate is found, the process should log the record in an error_log table. What is the best approach to achieve this?

16) A retail application needs to apply a discount based on customer membership level using a PL/SQL function. Which is the best way to implement this?

17) In a data warehousing project, you need to perform incremental data loading from a source to a staging table based on a timestamp field. What is the best practice to implement this in PL/SQL?

18) You are working on a billing system where you need to calculate the total invoice amount including tax for each order using a PL/SQL procedure. The tax rate is stored in a configuration table. How should you implement this?

19) Your team needs to implement an audit mechanism in the database to log changes to the employees table. What approach should be used?

20) A banking application requires a monthly report on account transactions with aggregated data for each account. Which PL/SQL technique is most efficient for this reporting task?

Login with your email & password

Sign up with your email & password

Signup/Registration Form