Oracle Certification Exam Quiz: MCQ!

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Sunil.aketi
S
Sunil.aketi
Community Contributor
Quizzes Created: 2 | Total Attempts: 3,933
Questions: 75 | Attempts: 2,170

SettingsSettingsSettings
Oracle Certification Exam Quiz: MCQ! - Quiz

What do you know about the Oracle Certification Exam? Would you like to put your knowledge to the test? The Oracle Certification Program certifies candidates on skills and experience pertaining to Oracle manufactured goods and technologies. Credentials are presented based on a combination of passing exams, training, and performance-based assignments, depending upon the level of certification. If you intend to learn more about the Oracle Certification Exam, look no further than this quiz.


Questions and Answers
  • 1. 

    CREATE OR REPLACE PACKAGE theater_pck IS PROCEDURE find_seats_sold (v_movie_id IN NUMBER DEFAULT 34, v_theater_id IN NUMBER); END theater_pck; CREATE OR REPLACE PACKAGE BODY theater_pck IS current_avg_cost_per_ticket NUMBER; PROCEDURE find_seats_sold (v_movie_id IN NUMBER DEFAULT 34, v_theater_id IN NUMBER) IS v_seats_sold gross_receipt.seats_sold%TYPE; v_budget studio.yearly_budget%TYPE; BEGIN SELECT seats_sold INTO v_seats_sold FROM gross_receipt WHERE movie_id = v_movie_id AND theater_id = v_theater_id; END find_seats_sold; FUNCTION get_budget (v_studio_id IN NUMBER) RETURN number IS v_yearly_budget NUMBER; BEGIN SELECT yearly_budget INTO v_yearly_budget FROM studio WHERE id = v_studio_id; RETURN v_yearly_budget; END get_budget; END theater_pck; Which statement about the CURRENT_AVG_COST_PER_TICKET variable is true?

    • A.

      It can only be referenced from outside the package

    • B.

      It can be referenced from outside and within the package.

    • C.

      It can be referenced by all constructs within the package.

    • D.

      It must be moved to the specification to compile successfully

    Correct Answer
    C. It can be referenced by all constructs within the package.
    Explanation
    The CURRENT_AVG_COST_PER_TICKET variable can be referenced by all constructs within the package. This means that it can be accessed and used by any procedure or function within the package, including the find_seats_sold procedure and the get_budget function. It does not need to be moved to the package specification in order to compile successfully.

    Rate this question:

  • 2. 

    While creating a package, you placed the function name in the specification and the body. Which type of construct have you created?

    • A.

      PUBLIC

    • B.

      Illegal

    • C.

      Private

    • D.

      One-time only

    Correct Answer
    A. PUBLIC
    Explanation
    By placing the function name in both the specification and the body, you have created a PUBLIC construct. This means that the function can be accessed and used by other parts of the code or other packages.

    Rate this question:

  • 3. 

    Examine this package specification and body: CREATE OR REPLACE PACKAGE theater_pck IS PROCEDURE find_seats_sold (v_movie_id IN NUMBER DEFAULT 34, v_theater_id IN NUMBER); END theater_pck; CREATE OR REPLACE PACKAGE BODY theater_pck IS current_avg_cost_per_ticket NUMBER; PROCEDURE find_seats_sold (v_movie_id IN NUMBER DEFAULT 34, v_theater_id IN NUMBER) IS v_seats_sold gross_receipt.seats_sold%TYPE; v_budget studio.yearly_budget%TYPE; BEGIN SELECT seats_sold INTO v_seats_sold FROM gross_receipt WHERE movie_id = v_movie_id AND theater_id = v_theater_id; END find_seats_sold; FUNCTION get_budget (v_studio_id IN NUMBER) RETURN number IS v_yearly_budget NUMBER; BEGIN SELECT yearly_budget INTO v_yearly_budget FROM studio WHERE id = v_studio_id; RETURN v_yearly_budget; END get_budget; END theater_pck;Which statement about the FIND_SEATS_SOLD procedure is true?

    • A.

      It can be referenced within a SQL statement.

    • B.

      It can only be referenced from within the package.

    • C.

      It can be referenced from within and outside of the package.

    • D.

      It cannot also be specified in the specification because it is specified in the body.

    Correct Answer
    C. It can be referenced from within and outside of the package.
    Explanation
    The FIND_SEATS_SOLD procedure can be referenced from both within and outside of the package. This means that the procedure can be called and used in SQL statements as well as in other parts of the code outside of the package.

    Rate this question:

  • 4. 

    Examine this package specification: CREATE OR REPLACE PACKAGE theater_package IS PROCEDURE find_cpt (v_movie_id IN NUMBER, v_cost_per_ticket IN OUT NUMBER); PROCEDURE update_theater (v_name IN VARCHAR2); PROCEDURE find_seats_sold (v_movie_id IN NUMBER DEFAULT 34, v_theater_id IN NUMBER); PROCEDURE add_theater; END theater_package; Which statement about the procedures in this specification is true?

    • A.

      They are public procedures

    • B.

      They are private procedures

    • C.

      Each procedure is missing code and, therefore, is illegal.

    • D.

      Each procedure contains an argument list and, therefore, is illegal.

    Correct Answer
    A. They are public procedures
    Explanation
    The procedures in this package specification are considered public procedures because they are declared without any access modifiers. Public procedures can be accessed and called by other programs or packages.

    Rate this question:

  • 5. 

    CREATE OR REPLACE PACKAGE theater_pck IS PROCEDURE find_seats_sold (v_movie_id IN NUMBER DEFAULT 34, v_theater_id IN NUMBER); END theater_pck; CREATE OR REPLACE PACKAGE BODY theater_pck IS current_avg_cost_per_ticket NUMBER; PROCEDURE find_seats_sold (v_movie_id IN NUMBER DEFAULT 34, v_theater_id IN NUMBER) IS v_seats_sold gross_receipt.seats_sold%TYPE; v_budget studio.yearly_budget%TYPE; BEGIN SELECT seats_sold INTO v_seats_sold FROM gross_receipt WHERE movie_id = v_movie_id AND theater_id = v_theater_id; END find_seats_sold; FUNCTION get_budget (v_studio_id IN NUMBER) RETURN number IS v_yearly_budget NUMBER; BEGIN SELECT yearly_budget INTO v_yearly_budget FROM studio WHERE id = v_studio_id; RETURN v_yearly_budget; END get_budget; END theater_pck; Which will successfully invoke the FIND_SEATS_SOLD procedure within SQL*Plus?

    • A.

      EXECUTE find_seats_sold (500,11);

    • B.

      Theater_pck.find_seats_sold (500,11);

    • C.

      EXECUTE theater_pck.find_seats_sold (500,11);

    • D.

      SELECT find_seats_sold(movie_id, theater_id) FROM gross_receipt;

    Correct Answer
    C. EXECUTE theater_pck.find_seats_sold (500,11);
    Explanation
    The correct answer is "EXECUTE theater_pck.find_seats_sold (500,11);" because it uses the correct syntax to invoke a procedure within SQL*Plus. The EXECUTE keyword is used to execute a stored procedure, followed by the fully qualified name of the procedure, which includes the package name "theater_pck" and the procedure name "find_seats_sold". The procedure is then passed the arguments 500 and 11.

    Rate this question:

  • 6. 

    CREATE OR REPLACE PACKAGE theater_pck IS v_total_budget NUMBER; PROCEDURE find_seats_sold (v_movie_id IN NUMBER DEFAULT 34, v_theater_id IN NUMBER); END theater_pck; CREATE OR REPLACE PACKAGE BODY theater_pck IS current_avg_cost_per_ticket NUMBER; PROCEDURE find_seats_sold (v_movie_id IN NUMBER DEFAULT 34, v_theater_id IN NUMBER) IS v_seats_sold gross_receipt.seats_sold%TYPE; v_budget studio.yearly_budget%TYPE; BEGIN SELECT seats_sold INTO v_seats_sold FROM gross_receipt WHERE movie_id = v_movie_id AND theater_id = v_theater_id; END find_seats_sold; FUNCTION get_budget (v_studio_id IN NUMBER) RETURN number IS v_yearly_budget NUMBER; BEGIN SELECT yearly_budget INTO v_yearly_budget FROM studio WHERE id = v_studio_id; RETURN v_yearly_budget; END get_budget; END theater_pck; Which statement about the V_TOTAL_BUDGET variable is true?

    • A.

      It must also be declared in the body.

    • B.

      It can only be referenced from inside the package

    • C.

      It can only be referenced from outside the package.

    • D.

      It can be referenced from inside and outside the package.

    Correct Answer
    D. It can be referenced from inside and outside the package.
    Explanation
    The V_TOTAL_BUDGET variable can be referenced from both inside and outside the package. This is because it is declared in the package specification, which allows it to be accessed by any program that uses the package. It does not need to be declared again in the package body.

    Rate this question:

  • 7. 

    CREATE OR REPLACE PACKAGE BODY theater_pck IS current_avg_cost_per_ticket NUMBER; PROCEDURE find_seats_sold (v_movie_id IN NUMBER DEFAULT 34, v_theater_id IN NUMBER) IS v_seats_sold gross_receipt.seats_sold%TYPE; v_budget studio.yearly_budget%TYPE; BEGIN SELECT seats_sold INTO v_seats_sold FROM gross_receipt WHERE movie_id = v_movie_id AND theater_id = v_theater_id; END find_seats_sold; FUNCTION get_budget (v_studio_id IN NUMBER) RETURN number IS v_yearly_budget NUMBER; BEGIN SELECT yearly_budget INTO v_yearly_budget FROM studio WHERE id = v_studio_id; RETURN v_yearly_budget; END get_budget; BEGIN current_avg_cost_per_ticket := 8.50; END theater_pck; Which statement about the value of CURRENT_AVG_COST_PER_TICKET is true?

    • A.

      It is 0 until explicitly referenced.

    • B.

      It is assigned 8.50 each time the package is referenced.

    • C.

      It is assigned 8.50 only when it is explicitly referenced.

    • D.

      It is assigned 8.50 when the package is first invoked within a session.

    Correct Answer
    D. It is assigned 8.50 when the package is first invoked within a session.
    Explanation
    The value of CURRENT_AVG_COST_PER_TICKET is assigned 8.50 when the package is first invoked within a session.

    Rate this question:

  • 8. 

    Examine this function: CREATE OR REPLACE FUNCTION get_budget (v_studio_id IN NUMBER) RETURN number IS v_yearly_budget NUMBER; BEGIN SELECT yearly_budget INTO v_yearly_budget FROM studio WHERE id = v_studio_id; RETURN v_yearly_budget; END; This function is owned by the account, PROD. The user, JSMITH, must execute this function. Which GRANT command(s) should be issued?

    • A.

      GRANT EXECUTE ON get_budget TO jsmith;

    • B.

      GRANT EXECUTE, SELECT ON studio TO jsmith;

    • C.

      GRANT EXECUTE, SELECT ON get_budget TO jsmith;

    • D.

      GRANT SELECT ON studio TO jsmith; GRANT EXECUTE ON get_budget TO jsmith;

    Correct Answer
    A. GRANT EXECUTE ON get_budget TO jsmith;
    Explanation
    The function "get_budget" is owned by the account PROD and the user JSMITH needs to execute this function. To grant JSMITH the permission to execute the function, the GRANT command "GRANT EXECUTE ON get_budget TO jsmith;" should be issued. This command specifically grants the EXECUTE privilege on the "get_budget" function to the user JSMITH.

    Rate this question:

  • 9. 

    Evaluate this statement: DROP PACKAGE dept_pack; Which statement is true?

    • A.

      This statement removes only the package body.

    • B.

      The statement removes only the package specification.

    • C.

      The statement removes the package specification and the package body.

    • D.

      This statement contains a syntax error.

    Correct Answer
    C. The statement removes the package specification and the package body.
    Explanation
    The given statement "DROP PACKAGE dept_pack;" is used to remove a package in a database. In this case, it removes both the package specification and the package body for the package named "dept_pack". Therefore, the correct answer is "The statement removes the package specification and the package body."

    Rate this question:

  • 10. 

    Examine this package specification and body: CREATE OR REPLACE PACKAGE theater_pck IS PROCEDURE find_seats_sold (v_movie_id IN NUMBER DEFAULT 34, v_theater_id IN NUMBER); END theater_pck; CREATE OR REPLACE PACKAGE BODY theater_pck IS current_avg_cost_per_ticket NUMBER; PROCEDURE find_seats_sold (v_movie_id IN NUMBER DEFAULT 34, v_theater_id IN NUMBER) IS v_seats_sold gross_receipt.seats_sold%TYPE; v_budget studio.yearly_budget%TYPE; BEGIN SELECT seats_sold INTO v_seats_sold FROM gross_receipt WHERE movie_id = v_movie_id AND theater_id = v_theater_id; END find_seats_sold; FUNCTION get_budget (v_studio_id IN NUMBER) RETURN number IS v_yearly_budget NUMBER; BEGIN SELECT yearly_budget INTO v_yearly_budget FROM studio WHERE id = v_studio_id; RETURN v_yearly_budget; END get_budget; END theater_pck; Which statement about the GET_BUDGET function is true?

    • A.

      It can be referenced within a SQL statement.

    • B.

      It can be referenced from outside of the package.

    • C.

      It can only be referenced from within the package.

    • D.

      It must also be specified in the specification because it is specified in the body.

    Correct Answer
    C. It can only be referenced from within the package.
    Explanation
    The GET_BUDGET function can only be referenced from within the package. This means that it cannot be called or used outside of the package. It is only accessible within the package's body, and cannot be accessed or called from any other part of the code or program.

    Rate this question:

  • 11. 

    Examine this function: CREATE OR REPLACE FUNCTION set_budget (v_studio_id IN NUMBER, v_new_budget IN NUMBER) RETURN number IS BEGIN UPDATE studio SET yearly_budget = v_new_budget WHERE id = v_studio_id; COMMIT; RETURN SQL%ROWCOUNT; END; While executing this in SQL*Plus, you want to see the value of SQL%ROWCOUNT displayed on the screen. Which line of code will accomplish this?

    • A.

      OUTPUT.PUT_LINE(TO_CHAR(SQL%ROWCOUNT));

    • B.

      DBMS_DEBUG.PUT_LINE(TO_CHAR(SQL%ROWCOUNT));

    • C.

      DBMS_OUTPUT.DISPLAY(TO_CHAR(SQL%ROWCOUNT));

    • D.

      DBMS_OUTPUT.PUT_LINE(TO_CHAR(SQL%ROWCOUNT));

    Correct Answer
    D. DBMS_OUTPUT.PUT_LINE(TO_CHAR(SQL%ROWCOUNT));
    Explanation
    The correct answer is DBMS_OUTPUT.PUT_LINE(TO_CHAR(SQL%ROWCOUNT));. This line of code will display the value of SQL%ROWCOUNT on the screen using the DBMS_OUTPUT.PUT_LINE function. The TO_CHAR function is used to convert the value of SQL%ROWCOUNT to a character string before displaying it.

    Rate this question:

  • 12. 

    Which command must you issue in SQL*Plus to display the result of the DBMS_OUTPUT package?

    • A.

      SET ECHO ON

    • B.

      SET OUTPUT ON

    • C.

      SET FEEDBACK ON

    • D.

      SET SERVEROUTPUT ON

    Correct Answer
    D. SET SERVEROUTPUT ON
    Explanation
    The correct answer is SET SERVEROUTPUT ON. This command enables the display of the result of the DBMS_OUTPUT package in SQL*Plus. It allows the output from procedures, functions, and triggers to be shown in the SQL*Plus command-line interface.

    Rate this question:

  • 13. 

    Which statement about packages is true?

    • A.

      A package can be called.

    • B.

      A package can be nested.

    • C.

      A package can be parameterized.

    • D.

      Package contents can be shared by multiple applications.

    Correct Answer
    D. Package contents can be shared by multiple applications.
    Explanation
    Packages in programming languages like Java allow for better organization and encapsulation of code. They can contain classes, interfaces, and other packages. One of the main advantages of using packages is that their contents can be shared by multiple applications. This means that different programs can access and use the classes and resources within a package, promoting code reuse and modularity. This helps in avoiding code duplication and makes development more efficient. Therefore, the statement "Package contents can be shared by multiple applications" is true.

    Rate this question:

  • 14. 

    Which statement about packages is true?

    • A.

      Package constructs stored in the database are public.

    • B.

      Package constructs defined within the package specification are private.

    • C.

      Private and public package constructs are both declared and defined within the package body.

    • D.

      A private package construct can only be referenced only by other constructs within the same package.

    Correct Answer
    D. A private package construct can only be referenced only by other constructs within the same package.
    Explanation
    Private package constructs are only accessible within the same package and cannot be referenced by any other constructs outside of the package. This means that they are not public and cannot be accessed by other packages or programs. Therefore, the statement "A private package construct can only be referenced only by other constructs within the same package" is true.

    Rate this question:

  • 15. 

    You decide to use packages to logically group related programming constructs. Which two types of constructs can be grouped within a package? (Choose two.)

    • A.

      View

    • B.

      Cursor

    • C.

      Variable

    • D.

      Database trigger

    • E.

      Application trigger

    Correct Answer(s)
    B. Cursor
    C. Variable
    Explanation
    Packages in programming are used to logically group related programming constructs. Two types of constructs that can be grouped within a package are cursors and variables. Cursors are used to retrieve and manipulate data from a database, while variables are used to store and manipulate data within a program. By grouping these constructs within a package, it allows for better organization, modularity, and reusability of code.

    Rate this question:

  • 16. 

    Examine this package specification and body: CREATE OR REPLACE PACKAGE theater_pck IS PROCEDURE find_seats_sold (v_movie_id IN NUMBER DEFAULT 34, v_theater_id IN NUMBER); END theater_pck; CREATE OR REPLACE PACKAGE BODY theater_pck IS current_avg_cost_per_ticket NUMBER; PROCEDURE find_seats_sold (v_movie_id IN NUMBER DEFAULT 34, v_theater_id IN NUMBER) IS v_seats_sold gross_receipt.seats_sold%TYPE; v_budget studio.yearly_budget%TYPE; BEGIN SELECT seats_sold INTO v_seats_sold FROM gross_receipt WHERE movie_id = v_movie_id AND theater_id = v_theater_id; END find_seats_sold; FUNCTION get_budget (v_studio_id IN NUMBER) RETURN number IS v_yearly_budget NUMBER; BEGIN SELECT yearly_budget INTO v_yearly_budget FROM studio WHERE id = v_studio_id; RETURN v_yearly_budget; END get_budget; END theater_pck; Which code will successfully assign a value to the CURRENT_AVG_COST_PER_TICKET variable within SQL*Plus?

    • A.

      BEGIN current_avg_cost_per_ticket := 6.75; END;

    • B.

      BEGIN theater_pck.current_avg_cost_per_ticket := 6.75; END;

    • C.

      BEGIN SELECT AVG(cost_per_ticket) INTO current_avg_cost_per_ticket FROM gross_receipt; END;

    • D.

      This variable is private to the package and cannot be directly assigned a value within SQL*Plus.

    Correct Answer
    D. This variable is private to the package and cannot be directly assigned a value within SQL*Plus.
    Explanation
    The explanation for the given correct answer is that the variable CURRENT_AVG_COST_PER_TICKET is declared within the package body and is not accessible outside of the package. Therefore, it cannot be directly assigned a value within SQL*Plus.

    Rate this question:

  • 17. 

    Examine this package specification and body: CREATE OR REPLACE PACKAGE theater_pck IS PROCEDURE find_seats_sold (v_movie_id IN NUMBER DEFAULT 34, v_theater_id IN NUMBER); END theater_pck; CREATE OR REPLACE PACKAGE BODY theater_pck IS current_avg_cost_per_ticket NUMBER; PROCEDURE find_seats_sold (v_movie_id IN NUMBER DEFAULT 34, v_theater_id IN NUMBER) IS v_seats_sold gross_receipt.seats_sold%TYPE; v_budget studio.yearly_budget%TYPE; BEGIN SELECT seats_sold INTO v_seats_sold FROM gross_receipt WHERE movie_id = v_movie_id AND theater_id = v_theater_id; END find_seats_sold; FUNCTION get_budget (v_studio_id IN NUMBER) RETURN number IS v_yearly_budget NUMBER; BEGIN SELECT yearly_budget INTO v_yearly_budget FROM studio WHERE id = v_studio_id; RETURN v_yearly_budget; END get_budget; END theater_pck; Which code will successfully invoke the GET_BUDGET function within SQL*Plus?

    • A.

      VARIABLE g_budget_amount NUMBER EXECUTE :g_budget_amount := get_budget(11);

    • B.

      VARIABLE g_budget_amount NUMBER EXECUTE theater_pck.get_budget(g_budget_amount, 11);

    • C.

      VARIABLE g_budget_amount NUMBER EXECUTE :g_budget_amount := theater_pck.get_budget(11);

    • D.

      This function cannot be referenced from outside the package.

    Correct Answer
    D. This function cannot be referenced from outside the package.
    Explanation
    The code to invoke the GET_BUDGET function within SQL*Plus is not provided. However, based on the given package specification and body, the GET_BUDGET function is not declared as a public function in the package. Therefore, it cannot be referenced or invoked from outside the package.

    Rate this question:

  • 18. 

    Examine this code: CREATE OR REPLACE PACKAGE prod_pack IS g_tax_rate NUMBER := .08; END prod_pack; Which statement about this code is true?

    • A.

      This package specification can exist without a body.

    • B.

      This package body can exist without a specification.

    • C.

      This package body cannot exist without a specification.

    • D.

      This package specification cannot exist without a body.

    Correct Answer
    A. This package specification can exist without a body.
    Explanation
    The given code is a package specification, which defines the interface of a package. In Oracle PL/SQL, a package specification can exist without a body. The package specification contains declarations of variables, constants, types, cursors, and subprograms that are accessible to other program units. The package body, on the other hand, contains the implementation of the subprograms declared in the specification. However, it is not necessary to have a package body for a package specification to exist.

    Rate this question:

  • 19. 

    Examine this procedure: PROCEDURE find_cpt (v_movie_id IN NUMBER, v_cost_per_ticket IN OUT NUMBER) IS BEGIN IF v_cost_per_ticket > 8.50 THEN SELECT cost_per_ticket INTO v_cost_per_ticket FROM gross_receipt WHERE movie_id = v_movie_id; END IF; END; You decide to create this procedure within the THEATER_PCK package. It will be accessible outside of the package. What will you add to the package specification?

    • A.

      PROCEDURE find_cpt (v_movie_id IN NUMBER, v_cost_per_ticket IN OUT NUMBER);

    • B.

      PUBLIC PROCEDURE find_cpt (v_movie_id IN NUMBER, v_cost_per_ticket IN OUT NUMBER);

    • C.

      PROCEDURE find_cpt (v_movie_id IN NUMBER, v_cost_per_ticket IN OUT NUMBER) IS BEGIN IF v_cost_per_ticket > 8.50 THEN SELECT cost_per_ticket INTO v_cost_per_ticket FROM gross_receipt WHERE movie_id = v_movie_id; END IF; END;

    • D.

      PUBLIC PROCEDURE find_cpt (v_movie_id IN NUMBER, v_cost_per_ticket IN OUT NUMBER) IS BEGIN IF v_cost_per_ticket > 8.50 THEN SELECT cost_per_ticket INTO v_cost_per_ticket FROM gross_receipt WHERE movie_id = v_movie_id; END IF; END;

    Correct Answer
    A. PROCEDURE find_cpt (v_movie_id IN NUMBER, v_cost_per_ticket IN OUT NUMBER);
    Explanation
    The correct answer is "PROCEDURE find_cpt (v_movie_id IN NUMBER, v_cost_per_ticket IN OUT NUMBER);". This is the correct syntax for adding a procedure to the package specification. It includes the procedure name, the input and output parameters, and their data types.

    Rate this question:

  • 20. 

    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?

    • A.

      Only the GET_TOTAL_FOR_YEAR variable must exist in the specification of the THEATER_PCK package.

    • B.

      Only the V_TOTAL_SEATS_SOLD_OVERALL variable must exist in the specification of the THEATER_PCK package.

    • C.

      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.

    • D.

      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.

    Correct Answer
    D. 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.
    Explanation
    For the code to be successful, 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. This means that both the variable and the function must be declared and defined in the package specification, allowing them to be accessed and used in the code. If either the variable or the function is missing from the package specification, the code will not be able to compile and execute successfully.

    Rate this question:

  • 21. 

    Examine this package specification and body: CREATE OR REPLACE PACKAGE theater_pck IS PROCEDURE find_seats_sold (v_movie_id IN NUMBER DEFAULT 34, v_theater_id IN NUMBER); END theater_pck; CREATE OR REPLACE PACKAGE BODY theater_pck IS current_avg_cost_per_ticket NUMBER; PROCEDURE find_seats_sold (v_movie_id IN NUMBER DEFAULT 34, v_theater_id IN NUMBER) IS v_seats_sold gross_receipt.seats_sold%TYPE; v_budget studio.yearly_budget%TYPE; BEGIN SELECT seats_sold INTO v_seats_sold FROM gross_receipt WHERE movie_id = v_movie_id AND theater_id = v_theater_id; END find_seats_sold; FUNCTION get_budget (v_studio_id IN NUMBER) RETURN number IS v_yearly_budget NUMBER; BEGIN SELECT yearly_budget INTO v_yearly_budget FROM studio WHERE id = v_studio_id; RETURN v_yearly_budget; END get_budget; END theater_pck; Which type of variable is CURRENT_AVG_COST_PER_TICKET?

    • A.

      Public

    • B.

      Private

    • C.

      Invalid

    • D.

      Constant

    Correct Answer
    B. Private
    Explanation
    In the given package body, the variable CURRENT_AVG_COST_PER_TICKET is declared before the PROCEDURE find_seats_sold. It is not declared within any procedure or function, making it a private variable. Private variables can only be accessed within the package body and are not visible to other packages or outside the package.

    Rate this question:

  • 22. 

    Procedures and functions are explicitly executed. This is different from a database trigger. When is a database trigger executed?

    • A.

      When the transaction is committed

    • B.

      During a data manipulation statement

    • C.

      When it is explicitly invoked by another construct

    • D.

      When an Oracle supplied package references the trigger

    Correct Answer
    B. During a data manipulation statement
    Explanation
    A database trigger is executed during a data manipulation statement. This means that whenever a specific action, such as an insert, update, or delete, is performed on the data in a table, the trigger associated with that table will be automatically executed. The trigger can be used to perform additional actions or enforce certain rules before or after the data manipulation statement is executed.

    Rate this question:

  • 23. 

    Examine this trigger: CREATE OR REPLACE TRIGGER audit_gross_receipt AFTER DELETE OR UPDATE OF seats_sold, cost_per_ticket ON gross_receipt BEGIN ... END; How many times will the trigger body execute upon invocation?

    • A.

      Once

    • B.

      Twice

    • C.

      Once for each row deleted or updated

    • D.

      Once for each row deleted or seats_sold_cost_per_ticket updated

    Correct Answer
    A. Once
    Explanation
    The trigger body will execute once upon invocation. This is because the trigger is defined as an "AFTER" trigger, which means it will only execute after the specified event (in this case, a delete or update of seats_sold or cost_per_ticket on the gross_receipt table) has occurred. Therefore, regardless of the number of rows affected by the delete or update statement, the trigger body will only execute once.

    Rate this question:

  • 24. 

    When a database trigger routine does not have to take place before the triggering event, which timing should you assign to the trigger?

    • A.

      On

    • B.

      Off

    • C.

      After

    • D.

      Before

    Correct Answer
    C. After
    Explanation
    When a database trigger routine does not have to take place before the triggering event, the timing that should be assigned to the trigger is "after". This means that the trigger will be executed after the triggering event has occurred.

    Rate this question:

  • 25. 

    Modifications to the THEATER table are not allowed during the last week in December. When creating a database trigger to enforce this rule, which timing will you use to be most efficient?

    • A.

      After

    • B.

      Weekly

    • C.

      Before

    • D.

      Monthly

    Correct Answer
    C. Before
    Explanation
    Using the "before" timing for the trigger will be most efficient in enforcing the rule that modifications to the THEATER table are not allowed during the last week in December. This is because the "before" timing allows the trigger to be executed before the modification takes place, effectively preventing any modifications from occurring during the specified time period. By using the "before" timing, the trigger can quickly and efficiently check the date and prevent any unauthorized modifications, saving resources and ensuring that the rule is enforced effectively.

    Rate this question:

  • 26. 

    CREATE OR REPLACE TRIGGER update_studio BEFORE UPDATE OF yearly_budget ON STUDIO FOR EACH ROW BEGIN ... END; Which event will invoke this trigger?

    • A.

      STUDIO table update

    • B.

      YEARLY_BUDGET column update

    • C.

      STUDIO table insert, update, or delete

    • D.

      Any column update other than YEARLY_BUDGET

    Correct Answer
    B. YEARLY_BUDGET column update
    Explanation
    This trigger will be invoked when there is an update specifically on the "YEARLY_BUDGET" column of the "STUDIO" table. It will not be triggered by any other column updates or by insert, update, or delete operations on the "STUDIO" table.

    Rate this question:

  • 27. 

    Examine this database trigger: CREATE OR REPLACE TRIGGER audit_gross_modification AFTER INSERT OR DELETE ON gross_receipt BEGIN INSERT INTO audit_gross VALUES (USER, SYSDATE); END; To test this trigger, you delete 30 rows from the GROSS_RECEIPT table. How many rows are inserted into the AUDIT_GROSS table due to this event?

    • A.

      1

    • B.

      30

    • C.

      31

    • D.

      None

    Correct Answer
    A. 1
    Explanation
    When the trigger is fired after deleting 30 rows from the GROSS_RECEIPT table, only one row is inserted into the AUDIT_GROSS table. This is because the trigger is designed to insert a single row into the AUDIT_GROSS table every time it is fired, regardless of the number of rows affected by the DELETE statement. Therefore, regardless of the number of rows deleted, only one row will be inserted into the AUDIT_GROSS table.

    Rate this question:

  • 28. 

    The auditing utility in Oracle records the type of data manipulation operation and not the actual changed values. To enhance auditing by capturing the new and old values, you create which type of trigger?

    • A.

      Row only

    • B.

      Statement only

    • C.

      Either statement or row

    • D.

      Neither statement or row

    Correct Answer
    A. Row only
    Explanation
    To enhance auditing by capturing the new and old values, you create a "row only" trigger. This type of trigger is specifically designed to capture the changes made to individual rows in a table. It allows you to track the old and new values of the modified data, providing more detailed information for auditing purposes. By using a "row only" trigger, you can ensure that the actual changed values are recorded along with the type of data manipulation operation.

    Rate this question:

  • 29. 

    For which trigger timing can you reference the NEW and OLD qualifiers?

    • A.

      Row only

    • B.

      Statement only

    • C.

      Statement and row

    • D.

      Oracle Forms trigger

    Correct Answer
    A. Row only
    Explanation
    The NEW and OLD qualifiers can be referenced for the "row only" trigger timing. This means that the qualifiers can be used when a trigger is fired for each row affected by a DML statement. In this case, the trigger can access the old and new values of the affected row.

    Rate this question:

  • 30. 

    Examine this trigger: CREATE OR REPLACE TRIGGER budget_trig AFTER INSERT ON studio FOR EACH ROW DECLARE v_sum NUMBER; BEGIN SELECT sum(yearly_budget) INTO v_sum FROM studio; UPDATE parent_company SET overall_budget = v_sum; END; You insert a row into the STUDIO table and receive this message: ORA-04091: table SCOTT.STUDIO is mutating, trigger/function may not see it How do you correct this error?

    • A.

      Change the timing to BEFORE.

    • B.

      Remove the AFTER INSERT ON clause.

    • C.

      Remove the SUM function; it is not allowed in database triggers.

    • D.

      Convert it to a statement level database trigger by removing FOR EACH ROW.

    Correct Answer
    D. Convert it to a statement level database trigger by removing FOR EACH ROW.
    Explanation
    The error message "ORA-04091: table SCOTT.STUDIO is mutating, trigger/function may not see it" indicates that the trigger is trying to access the table it is defined on (STUDIO) while it is still being modified. To correct this error, the trigger should be converted to a statement level trigger by removing the "FOR EACH ROW" clause. This change ensures that the trigger operates on the entire statement rather than individual rows, avoiding the mutation error.

    Rate this question:

  • 31. 

    Examine this database trigger: CREATE OR REPLACE TRIGGER update_show_gross {additional trigger information} BEGIN {additional code} END; This trigger should execute for each row when the SEATS_SOLD or COST_PER_TICKET columns are updated and when a row is inserted into the GROSS_RECEIPT table. Which trigger information must you add?

    • A.

      BEFORE (gross_receipt, seats_sold, cost_per_ticket) INSERT, UPDATE

    • B.

      BEFORE INSERT OR UPDATE OF seats_sold, cost_per_ticket ON gross_receipt

    • C.

      BEFORE INSERT OR UPDATE(seats_sold, cost_per_ticket) ON gross_receipt FOR EVERY ROW

    • D.

      BEFORE INSERT OR UPDATE OF seats_sold, cost_per_ticket ON gross_receipt FOR EACH ROW

    Correct Answer
    D. BEFORE INSERT OR UPDATE OF seats_sold, cost_per_ticket ON gross_receipt FOR EACH ROW
    Explanation
    The trigger should execute for each row when the SEATS_SOLD or COST_PER_TICKET columns are updated and when a row is inserted into the GROSS_RECEIPT table. Therefore, the trigger information must specify that the trigger should be executed before an insert or update operation on the SEATS_SOLD and COST_PER_TICKET columns of the GROSS_RECEIPT table. Additionally, the trigger should be executed for each row affected by the insert or update operation.

    Rate this question:

  • 32. 

    Each month a SQL*Loader application is executed to insert approximately 1 million rows into the GROSS_RECEIPT table. This table has three database triggers that execute for each row inserted. Which command can you issue immediately before the SQL*Loader operation to improve performance?

    • A.

      DISABLE TRIGGERS ON gross_receipt;

    • B.

      DISABLE ALL TRIGGERS ON gross_receipt;

    • C.

      ALTER TRIGGER ALL DISABLE ON gross_receipt;

    • D.

      ALTER TABLE gross_receipt DISABLE ALL TRIGGERS;

    Correct Answer
    D. ALTER TABLE gross_receipt DISABLE ALL TRIGGERS;
    Explanation
    Disabling all triggers on the "gross_receipt" table using the "ALTER TABLE" command can improve performance during the SQL*Loader operation. By disabling the triggers, the database will not have to execute them for each row inserted, which can reduce the overall processing time and improve performance. This allows the SQL*Loader application to insert the rows more efficiently into the table.

    Rate this question:

  • 33. 

    The CHECK_THEATER trigger of the THEATER table has been disabled. Which command can you issue to enable this trigger?

    • A.

      ENABLE check_theater;

    • B.

      ENABLE TRIGGER check_theater;

    • C.

      ALTER TRIGGER check_theater ENABLE;

    • D.

      ALTER TABLE check_theater ENABLE check_theater;

    Correct Answer
    C. ALTER TRIGGER check_theater ENABLE;
    Explanation
    The correct command to enable a trigger in this scenario is "ALTER TRIGGER check_theater ENABLE;". This command specifically enables the "check_theater" trigger on the table. The other options are not valid commands for enabling a trigger.

    Rate this question:

  • 34. 

    The AUDIT_THEATER trigger on the THEATER table is no longer needed and must be removed. Which command will successfully remove this trigger from the database?

    • A.

      DROP audit_theater;

    • B.

      DROP TRIGGER audit_theater;

    • C.

      ALTER TRIGGER audit_theater DROP;

    • D.

      ALTER TABLE theater DROP TRIGGER audit_theater;

    Correct Answer
    B. DROP TRIGGER audit_theater;
    Explanation
    The correct answer is "DROP TRIGGER audit_theater;". This command is used to remove a trigger from the database. The "DROP" keyword is used to indicate that the trigger is being dropped, and "audit_theater" specifies the name of the trigger that needs to be removed.

    Rate this question:

  • 35. 

    Due to a disk failure, the AUDIT_THEATER table is unavailable until further notice. The CHECK_THEATER database trigger references this table when a DML operation is performed on the THEATER table. Which command should you issue to prevent this database trigger from executing until this problem is resolved?

    • A.

      ALTER TRIGGER check_theater DROP;

    • B.

      MODIFY TRIGGER check_theater DROP;

    • C.

      ALTER TRIGGER check_theater DISABLE;

    • D.

      MODIFY TRIGGER check_theater DISABLE;

    Correct Answer
    C. ALTER TRIGGER check_theater DISABLE;
    Explanation
    The correct answer is "ALTER TRIGGER check_theater DISABLE." This command will disable the "check_theater" trigger, preventing it from executing until the problem with the AUDIT_THEATER table is resolved.

    Rate this question:

  • 36. 

    You created a database trigger that will be executed for all data manipulation statements on the THEATER table. Within the code, you will determine which type of manipulation has caused the trigger to execute. Which would you use to test for the type of manipulation being performed?

    • A.

      DBMS_SQL

    • B.

      DBMS_TRIGGER

    • C.

      DBMS_CHECK_MANIPULATION_TYPE

    • D.

      DELETING, UPDATING, and INSERTING

    Correct Answer
    D. DELETING, UPDATING, and INSERTING
    Explanation
    To test for the type of manipulation being performed, you would use "DELETING, UPDATING, and INSERTING". These are the options that represent the different types of data manipulation statements that can be executed on the THEATER table. By checking which type of manipulation is being performed, you can determine the appropriate action to take within the trigger code.

    Rate this question:

  • 37. 

    You created a database trigger that will be executed for all data manipulation statements on the THEATER table. Within the code, you will determine which type of manipulation has caused the trigger to execute. Which would you use to test for the type of manipulation being performed?

    • A.

      BEFORE (gross_receipt) DELETE, INSERT, UPDATE

    • B.

      AFTER DELETE OR INSERT OR UPDATE ON gross_receipt

    • C.

      BEFORE DELETE OR INSERT OR UPDATE ON gross_receipt

    • D.

      BEFORE DELETE OR INSERT OR UPDATE ON gross_receipt FOR EACH ROW

    Correct Answer
    C. BEFORE DELETE OR INSERT OR UPDATE ON gross_receipt
    Explanation
    The correct answer is "BEFORE DELETE OR INSERT OR UPDATE ON gross_receipt". This is the correct syntax for creating a trigger that will be executed before any delete, insert, or update operation is performed on the gross_receipt table. The "BEFORE" keyword indicates that the trigger will be executed before the operation takes place, and the "DELETE OR INSERT OR UPDATE" keywords specify the types of operations that will trigger the execution of the trigger. The "ON gross_receipt" specifies the table on which the trigger will be applied.

    Rate this question:

  • 38. 

    You created a database trigger that will be executed for all data manipulation statements on the THEATER table. Within the code, you will determine which type of manipulation has caused the trigger to execute. Which would you use to test for the type of manipulation being performed?

    • A.

      DBMS_SQL

    • B.

      DBMS_TRIGGER

    • C.

      DBMS_CHECK_MANIPULATION_TYPE

    • D.

      DELETING, UPDATING, and INSERTING

    Correct Answer
    D. DELETING, UPDATING, and INSERTING
    Explanation
    To test for the type of manipulation being performed, you would use the options DELETING, UPDATING, and INSERTING. These options represent the different types of data manipulation statements that can be executed on the THEATER table. By checking which of these options is true within the trigger code, you can determine the type of manipulation that caused the trigger to execute.

    Rate this question:

  • 39. 

    Examine this function: CREATE OR REPLACE FUNCTION set_budget (v_studio_id IN NUMBER, v_new_budget IN NUMBER) RETURN BOOLEAN IS BEGIN UPDATE studio SET yearly_budget = v_new_budget WHERE id = v_studio_id; IF SQL%FOUND THEN RETURN TRUE; ELSE RETURN FALSE; END IF; COMMIT; END; Which code will successfully invoke this function?

    • A.

      SELECT id, set_budget(11,500000000) FROM studio;

    • B.

      DECLARE v_updated_flag BOOLEAN; BEGIN set_budget(11,500000000); END;

    • C.

      VARIABLE g_updated_flag BOOLEAN BEGIN g_updated_flag := set_budget(11,500000000); END;

    • D.

      DECLARE v_updated_flag BOOLEAN; BEGIN v_updated_flag := set_budget(11,500000000); END;

    Correct Answer
    D. DECLARE v_updated_flag BOOLEAN; BEGIN v_updated_flag := set_budget(11,500000000); END;
    Explanation
    The correct answer is the DECLARE block because it declares a variable v_updated_flag of type BOOLEAN and assigns the result of the set_budget function to it. This allows the function to be invoked and the result to be stored in the variable for further use.

    Rate this question:

  • 40. 

    Examine this function: CREATE OR REPLACE FUNCTION get_budget (v_studio_id IN NUMBER) RETURN number IS v_yearly_budget NUMBER; BEGIN SELECT yearly_budget INTO v_yearly_budget FROM studio WHERE id = v_studio_id; RETURN v_yearly_budget; END; Which set of statements will successfully invoke this function within SQL*Plus?

    • A.

      VARIABLE g_yearly_budget NUMBER :g_yearly_budget := GET_BUDGET(11);

    • B.

      VARIABLE g_yearly_budget NUMBER EXECUTE g_yearly_budget := GET_BUDGET(11);

    • C.

      VARIABLE g_yearly_budget NUMBER EXECUTE :g_yearly_budget := GET_BUDGET(11);

    • D.

      VARIABLE :g_yearly_budget NUMBER EXECUTE :g_yearly_budget := GET_BUDGET(11);

    Correct Answer
    C. VARIABLE g_yearly_budget NUMBER EXECUTE :g_yearly_budget := GET_BUDGET(11);
    Explanation
    The correct set of statements to successfully invoke the function within SQL*Plus is to declare a variable "g_yearly_budget" of type NUMBER using the "VARIABLE" command, and then use the "EXECUTE" command to assign the result of the function call "GET_BUDGET(11)" to the variable ":g_yearly_budget".

    Rate this question:

  • 41. 

    Examine this function: CREATE OR REPLACE FUNCTION get_budget (v_studio_id IN NUMBER, v_max_budget IN NUMBER) RETURN number IS v_yearly_budget NUMBER; BEGIN SELECT yearly_budget INTO v_yearly_budget FROM studio WHERE id = v_studio_id; IF v_yearly_budget > v_max_budget THEN RETURN v_max_budget; ELSE RETURN v_yearly_budget; END IF; END; Which set of statements will successfully invoke this function within SQL*Plus?

    • A.

      SELECT id, name, get_budget(id,200) FROM studio;

    • B.

      VARIABLE g_yearly_budget NUMBER EXECUTE g_yearly_budget := get_budget(11, 4000000000);

    • C.

      VARIABLE g_yearly_budget NUMBER RUN :g_yearly_budget := get_budget(v_studio_id => 11,v_max_budget => 4000000000);

    • D.

      VARIABLE g_yearly_budget NUMBER RUN :g_yearly_budget := get_budget(v_studio_id => 11,v_max_budget => 4000000000);

    Correct Answer
    A. SELECT id, name, get_budget(id,200) FROM studio;
    Explanation
    The correct answer is the first option. This is because it correctly invokes the function "get_budget" within the SQL query by passing the "id" column from the "studio" table as the first argument and the value 200 as the second argument. It retrieves the "id" and "name" columns from the "studio" table and also includes the result of the "get_budget" function in the output.

    Rate this question:

  • 42. 

    For which purpose are formal parameters used when creating functions?

    • A.

      Restricting pragma references

    • B.

      Passing values to the function

    • C.

      Bypassing directives to the compiler

    • D.

      Prompting the end user for information

    Correct Answer
    B. Passing values to the function
    Explanation
    Formal parameters are used when creating functions to pass values to the function. These parameters act as placeholders for the values that will be provided when the function is called. By passing values to the function through formal parameters, the function can perform operations on these values and return a result or perform a specific task based on the provided values. This allows for the reuse and flexibility of functions, as different values can be passed to achieve different outcomes.

    Rate this question:

  • 43. 

    A stored function can be invoked in many different ways. Which invocation example is NOT valid?

    • A.

      Executing the stored function within an INSERT statement

    • B.

      Executing the stored function within a server-side function

    • C.

      Executing the stored function within a client-side function

    • D.

      Executing the stored function within a CHECK constraint of a table

    Correct Answer
    D. Executing the stored function within a CHECK constraint of a table
  • 44. 

    How do functions simplify maintainability?

    • A.

      By limiting changes to logic to one location

    • B.

      By eliminating the need for an executable section

    • C.

      By eliminating the need for the storage of object code

    • D.

      By ignoring side effects when invoked from within a SQL statement

    Correct Answer
    A. By limiting changes to logic to one location
    Explanation
    Functions simplify maintainability by limiting changes to logic to one location. This means that if there is a change needed in the logic of a function, it only needs to be made in that one location. This reduces the chances of introducing errors or inconsistencies, as the logic is centralized and can be easily managed. It also makes it easier to understand and debug the code, as the logic is contained within a specific function. By limiting changes to one location, functions promote modularity and encapsulation, making the code easier to maintain and update.

    Rate this question:

  • 45. 

    A stored function can be invoked in many different ways. Which invocation example is NOT valid?

    • A.

      Executing the stored function within an INSERT statement

    • B.

      Executing the stored function within a server-side function

    • C.

      Executing the stored function within a client-side function

    • D.

      Executing the stored function within the DEFAULT clause of the CREATE TABLE statement

    Correct Answer
    D. Executing the stored function within the DEFAULT clause of the CREATE TABLE statement
  • 46. 

    Examine this statement: SELECT id, theater_pck.get_budget(id) FROM studio; What must be true about the GET_BUDGET function for this statement to be successful?

    • A.

      It must be remote.

    • B.

      It must not modify the database.

    • C.

      It must also exist as a stand-alone function.

    • D.

      It must only exist in the body of THEATER_PCK.

    Correct Answer
    B. It must not modify the database.
    Explanation
    The statement is selecting the ID and the budget of a theater from the studio table. In order for this statement to be successful, the GET_BUDGET function must not modify the database. This means that the function should only retrieve data and not make any changes to the underlying database.

    Rate this question:

  • 47. 

    Examine this function: CREATE OR REPLACE FUNCTION get_budget RETURN number IS v_yearly_budget NUMBER; BEGIN SELECT yearly_budget INTO v_yearly_budget FROM studio WHERE id = v_studio_id; RETURN v_yearly_budget; END; What additional code is needed to compile this function successfully?

    • A.

      Remove the first RETURN statement.

    • B.

      Change "RETURN number" to "OUTPUT number".

    • C.

      Add "(v_studio_id IN NUMBER)" right after the IS keyword.

    • D.

      Add "(v_studio_id IN NUMBER)" right before the RETURN statement of the header.

    Correct Answer
    D. Add "(v_studio_id IN NUMBER)" right before the RETURN statement of the header.
    Explanation
    To compile the given function successfully, the additional code needed is to add "(v_studio_id IN NUMBER)" right before the RETURN statement of the header. This is necessary because the function is using the variable v_studio_id in the SELECT statement, but it is not declared in the function header. By adding this parameter in the header, the function will be able to compile and execute correctly.

    Rate this question:

  • 48. 

    Which code successfully calculates commission returning it to the calling environment?

    • A.

      CREATE OR REPLACE FUNCTION calc_comm (v_emp_id IN NUMBER) RETURN number IS v_total NUMBER; BEGIN SELECT SUM(ord.total) INTO v_total FROM ord,customer WHERE ord.custid = customer.custid AND customer.repid = v_emp_id; END;

    • B.

      CREATE OR REPLACE FUNCTION calc_comm (v_emp_id IN NUMBER) IS v_total NUMBER; BEGIN SELECT SUM(ord.total) INTO v_total FROM ord,customer WHERE ord.custid = customer.custid AND customer.repid = v_emp_id; RETURN (v_total * .20); END;

    • C.

      CREATE OR REPLACE FUNCTION calc_comm (v_emp_id IN NUMBER) IS RETURN number v_total NUMBER; BEGIN SELECT SUM(ord.total) INTO v_total FROM ord,customer WHERE ord.custid = customer.custid AND customer.repid = v_emp_id; RETURN (v_total * .20); END;

    • D.

      CREATE OR REPLACE FUNCTION calc_comm (v_emp_id IN NUMBER) RETURN number IS v_total NUMBER; BEGIN SELECT SUM(ord.total) INTO v_total FROM ord,customer WHERE ord.custid = customer.custid AND customer.repid = v_emp_id; RETURN (v_total * .20); END;

    Correct Answer
    D. CREATE OR REPLACE FUNCTION calc_comm (v_emp_id IN NUMBER) RETURN number IS v_total NUMBER; BEGIN SELECT SUM(ord.total) INTO v_total FROM ord,customer WHERE ord.custid = customer.custid AND customer.repid = v_emp_id; RETURN (v_total * .20); END;
    Explanation
    The correct answer is the third option: CREATE OR REPLACE FUNCTION calc_comm (v_emp_id IN NUMBER) IS RETURN number v_total NUMBER; BEGIN SELECT SUM(ord.total) INTO v_total FROM ord,customer WHERE ord.custid = customer.custid AND customer.repid = v_emp_id; RETURN (v_total * .20); END;

    This option successfully calculates the commission by selecting the sum of the total orders for a specific employee ID and multiplying it by 0.20. It also includes the necessary syntax for creating a function in Oracle PL/SQL.

    Rate this question:

  • 49. 

    You have just created a PL/SQL user-defined function called CALC_COMM. Which statement will successfully test it?

    • A.

      EXECUTE calc_comm;

    • B.

      SELECT * FROM calc_comm(emp);

    • C.

      EXECUTE calc_comm(SELECT total FROM ord);

    • D.

      SELECT * FROM ord GROUP BY ordid HAVING calc_comm(total) > 5000;

    Correct Answer
    D. SELECT * FROM ord GROUP BY ordid HAVING calc_comm(total) > 5000;
    Explanation
    The correct answer is "SELECT * FROM ord GROUP BY ordid HAVING calc_comm(total) > 5000;". This statement will successfully test the PL/SQL user-defined function CALC_COMM. It selects all rows from the ORD table, groups them by the ORDID column, and then applies the CALC_COMM function to the TOTAL column. It filters out the rows where the result of the CALC_COMM function is greater than 5000. This statement ensures that the function is being used correctly and returns the desired results.

    Rate this question:

  • 50. 

    Which subprogram type can be invoked from within a SQL statement?

    • A.

      Function

    • B.

      Procedure

    • C.

      Public packaged procedure

    • D.

      Private packaged procedure

    • E.

      Private packaged function

    Correct Answer
    A. Function
    Explanation
    A function can be invoked from within a SQL statement. Functions are subprograms that can be called within SQL statements to perform a specific task and return a value. They can be used to manipulate data, perform calculations, or retrieve specific information from the database. Unlike procedures, functions always return a value and can be used in expressions or as part of a query. Therefore, a function is the correct subprogram type that can be invoked from within a SQL statement.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Jul 04, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Mar 10, 2009
    Quiz Created by
    Sunil.aketi
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.