What is the correct definition of the persistent state of a packaged variable?

What is the correct definition of the persistent state of a packaged variable?
A. It is a private variable defined in a procedure or function within a package body whose value is consistent within a user session.
B. It is a public variable in a package specification whose value is consistent within a user session.
C. It is a private variable in a package body whose value is consistent across all current active sessions.
D. It is a public variable in a package specification whose value is always consistent across all current active sessions.

Download Printable PDF. VALID exam to help you PASS.

2 thoughts on “What is the correct definition of the persistent state of a packaged variable?

  1. I think correct answer is B.
    Reference:

    https://docs.oracle.com/cd/B10500_01/appdev.920/a96624/09_packs.htm

    “Private vs Public Items in Packages
    Look again at the package emp_actions. The package body declares a variable named number_hired, which is initialized to zero. Unlike items declared in the spec of emp_actions, items declared in the body are restricted to use within the package. Therefore, PL/SQL code outside the package cannot reference the variable number_hired. Such items are called private.

    However, items declared in the spec of emp_actions, such as the exception invalid_salary, are visible outside the package. Therefore, any PL/SQL code can reference the exception invalid_salary. Such items are called public.

    When you must maintain items throughout a session or across transactions, place them in the declarative part of the package body. For example, the value of number_hired is kept between calls to hire_employee within the same session. The value is lost when the session ends.

    If you must also make the items public, place them in the package spec. For example, the constant minimum_balance declared in the spec of the package bank_transactions is available for general use.”

    https://docs.oracle.com/cd/E11882_01/appdev.112/e25519/packages.htm#LNPLS99924

    “Package public variables and cursors can persist for the life of a session. They can be shared by all subprograms that run in the environment. They let you maintain data across transactions without storing it in the database. “

  2. I think correct answer is B.
    Reference:

    https://docs.oracle.com/cd/B10500_01/appdev.920/a96624/09_packs.htm

    “Private Versus Public Items in Packages
    Look again at the package emp_actions. The package body declares a variable named number_hired, which is initialized to zero. Unlike items declared in the spec of emp_actions, items declared in the body are restricted to use within the package. Therefore, PL/SQL code outside the package cannot reference the variable number_hired. Such items are called private.

    However, items declared in the spec of emp_actions, such as the exception invalid_salary, are visible outside the package. Therefore, any PL/SQL code can reference the exception invalid_salary. Such items are called public.

    When you must maintain items throughout a session or across transactions, place them in the declarative part of the package body. For example, the value of number_hired is kept between calls to hire_employee within the same session. The value is lost when the session ends.

    If you must also make the items public, place them in the package spec. For example, the constant minimum_balance declared in the spec of the package bank_transactions is available for general use.”

    https://docs.oracle.com/cd/E11882_01/appdev.112/e25519/packages.htm#LNPLS99924

    “Package public variables and cursors can persist for the life of a session. They can be shared by all subprograms that run in the environment. They let you maintain data across transactions without storing it in the database. “

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.