Search code examples
oracleplsqloracle-apexplsql-package

How to compile Oracle package with APEX functions?


I am trying to compile an Oracle package that my colleague left to me. However, the package spec. contains some functions that may not be built in my Oracle environment.

create or replace PACKAGE AAA IS
  g_session     VARCHAR2(400) := v('SESSION');
  g_user        VARCHAR2(400) := v('APP_USER');

  PROCEDURE p_1;
END AAA;

When I try to compile the package spec in Oracle developer, I states

'V' must be declared.

Since the colleague that left me this code is no longer available, I have no idea of how to compile them.


Solution

  • The v function is meaningful in Apex environment; it'll return the value of the parameter you pass to it. In your example, that would be something like this:

    v('SESSION') = 32604633949883   --> session ID
    v('APP_USER') = LITTLEFOOT      --> user logged to Apex
    

    Apart from Apex environment, the v function works from your named PL/SQL stored procedures, packages and such.

    As you aren't capable of compiling that code, it seems that there's no Apex installed in the database that contains that package. Is there? If not, well, you won't be able to compile it so you can:

    • install Apex, or
    • remove the v function calls from your code