Trying to implement a VPD policy but got the following error ORA-20001

hey good day,
I'm trying to implement a VPD policy to my application. After I have performed the below task (Label 1) in oracle 10g database. When I'm about to access my application page in ApEx 3.2.1 I got the following error
ORA-20001: get_dbms_sql_cursor error ORA-28110: policy function or package CHARLES.VPD_PREDICATE has error
any form of assistance will be greatly appreciated.
thanks in advance
Label 1
USER is "VPD_ADMIN"
SQL> create or replace context empnum_ctx using set_empnum_ctx_pkg;
Context created.
SQL> CREATE OR REPLACE PACKAGE set_empnum_ctx_pkg IS
  2    PROCEDURE set_empnum;
  3  END;
  4  /
Package created.
SQL> CREATE OR REPLACE PACKAGE BODY set_empnum_ctx_pkg IS
  2    PROCEDURE set_empnum IS
  3     emp_id NUMBER;
  4    BEGIN
  5     SELECT EMPNUM INTO emp_id FROM CHARLES.INSTRUCTOR
  6     WHERE upper(username) = nvl(v('APP_USER'), USER);
  7     DBMS_SESSION.SET_CONTEXT('empnum_ctx', 'empnum', emp_id);
  8
  9    EXCEPTION
10      WHEN NO_DATA_FOUND THEN NULL;
11    END;
12  END;
13  /
Package body created.
SQL> create or replace package vpd_policy as
  2    function vpd_predicate(object_schema in varchar2 default null, object_name in varchar2 default null)
  3     return varchar2;
  4  end;
  5  /
Package created.
SQL> create or replace package body vpd_policy as  function vpd_predicate(
  2   object_schema in varchar2 default null, object_name in varchar2 default null)
  3     return varchar2 as
  4
  5      BEGIN
  6     if (USER = 'ADMIN') and (v('APP_USER') is null) or
  7        (USER = 'MICHAEL.GRAY') and (v('APP_USER') is NULL) then
  8       return '';
  9     else
10       return '(
11             exists (
12                     select  "INSTRUCTOR"."EMPNUM" as "EMPNUM",
13                             "INSTRUCTOR"."FIRSTNAME" as "FIRSTNAME",
14                             "INSTRUCTOR"."LASTNAME" as "LASTNAME",
15                             "LOAD"."COURSEID" as "COURSEID",
16                             "COURSE"."CREDIT" as "CREDIT",
17                             "COURSE"."HPW" as "HPW",
18                             "LOAD"."CAMPID" as "CAMPID",
19                             "LOAD"."YR" as "YR",
20                             "INSTRUCTOR"."POS" as "POS",
21                             "INSTRUCTOR"."USERNAME" as "USERNAME",
22                             "INSTRUCTOR"."DEPARTMENT_NAME" as "DEPARTMENT_NAME",
23                             "LOAD"."SEMESTER" as "SEMESTER"
24                     from    "COURSE" "COURSE",
25                             "INSTRUCTOR" "INSTRUCTOR",
26                             "LOAD" "LOAD"
27                     where   "INSTRUCTOR"."EMPNUM"="LOAD"."EMPNUM"
28                     and     "LOAD"."COURSEID"="COURSE"."COURSEID"
29                     and     department_name = (
30                                     select department_name from departments
31                                     where upper (assigned_to) = nvl(v(''APP_USER''),USER) )
32                                     )
33
34                     or upper(username) = nvl(v(''APP_USER''), USER)
35                                                ) ';
36
37     END IF;
38  END vpd_predicate;
39  END vpd_policy;
40  /
Package body created.
SQL> begin
  2  dbms_rls.add_policy(
  3  object_schema => 'charles',
  4  object_name => 'load',
  5  policy_name => 'Loading Policy',
  6  function_schema => 'charles',
  7  policy_function => 'vpd_predicate',
  8  statement_types => 'select, update, insert, delete');
  9  end;
10  /
PL/SQL procedure successfully completed.

ORA-20001 isn't an Oracle error message it was coded into your application by a developer: Look it up.
Consider too the following:
EXCEPTION
   WHEN NO_DATA_FOUND THEN NULL;so if the employee identifier is not found ... is this really what you want? If an employee isn't valid shouldn't you know it?

Similar Messages

Maybe you are looking for

  • Change CSS styles for Acces Web App

    Here's the problem, the #s4-mini-header needs to be set to display:none so the SharePoint header is not shown.  Ideally this would be conditional based on group membership (i.e. Site Owners would see the section, for read only it would be hidden) I n

  • How can i get iOS 5 in mi iPhone 3GS?

    I need to downlode iOS 5 but i don't now How 

  • Viewing PDF comments on Mobile deivices

    Hello! I have had several clients complain that they cannot see the comments I make on their PDFs when they try to view them on mobile devices.  Is there a fix for this or perhaps an app that will enable the comments to show up?

  • New Feature Phones in the Future?

    I have been looking at the feature phones that verizon has currently on their website and they haven't changed for some time. As of Feb 1 the data packages have changed and was wondering which of the feature phones currently on the list would require

  • Analyzer 7 Across the WAN using NAT addresses

    We have acquired several companies that have their own internal ip addresses that are duplicates of some of our internal ip addresses. To overcome this we use Network Address Translation (NAT). However, we cannot get Analyzer to work with these NAT a