Under the username "MY_ADMIN", I have successfully created a table called "NOTIFICATIONS" and a view called "V_NOTIFICATIONS". In the "V_NOTIFICATIONS" view, I successfully created a trigger and a package that does what the user tries to insert into the view and inserts it into the table. The trigger "V_NOTIFICATIONS" and the package also perform update and delete functions in the table when the user tries to perform update and delete functions in the view.
I did this with many views in the project I'm working on now, since many views sit on top of many different tables, however, when I try to insert a record into this view, I get "ORA-01031: not enough privilege.
I can insert directly into the table using the same code that is in the package, but not in the form. Any help on this would be greatly appreciated. Here is the requested code:
BROWSE: (When UNION is commented below, the package works as expected)
CREATE OR REPLACE FORCE VIEW "MY_ADMIN"."V_NOTIFICATIONS" AS
SELECT N_ID,
NOTIFICATION_TYPE,
CASE WHEN NOTIFICATION_DESC = 'C' THEN 'Copy' ELSE 'Send to' END NOTIFICATION_DESC,
CASE WHEN CONTACT_TYPE = 'D' THEN 'Department' ELSE 'Contact' END CONTACT_TYPE,
A.AU_USER_ID,
A.CONTACT_NAME,
D.DEPARTMENT_ID,
D.DEPT_DESC
FROM NOTIFICATIONS AN,
(SELECT A1.AU_USER_ID,
AU.FIRST_NAME || ' ' || AU.LAST_NAME CONTACT_NAME
FROM APP_USERS_CONTACT_INFO A1,
APPLICATION_USERS AU
WHERE A1.AU_USER_ID = AU.USER_ID
) A,
(SELECT DEPARTMENT_ID,
DESCRIPTION DEPT_DESC
FROM DEPARTMENTS
UNION
SELECT 0 DEPARTMENT_ID,
NULL DEPT_DESC
FROM DUAL) D
WHERE NVL(AN.AU_USER_ID,0) = A.AU_USER_ID
AND NVL(AN.D_DEPARTMENT_ID,0) = D.DEPARTMENT_ID;
PACKAGE:
CREATE OR REPLACE PACKAGE NOTIFICATIONS_PKG AS
PROCEDURE INSERT_NOTIFICATION(P_N_ROW V_NOTIFICATIONS%ROWTYPE);
END NOTIFICATIONS_PKG;
/
CREATE OR REPLACE PACKAGE BODY NOTIFICATIONS_PKG AS
PROCEDURE INSERT_NOTIFICATION(P_N_ROW V_NOTIFICATIONS%ROWTYPE) IS
L_NOTIFICATION_DESC VARCHAR2(1);
L_CONTACT_TYPE VARCHAR2(1);
BEGIN
CASE P_N_ROW.NOTIFICATION_DESC
WHEN 'Copy' THEN
L_NOTIFICATION_DESC := 'C';
ELSE
L_NOTIFICATION_DESC := 'S';
END CASE;
CASE P_N_ROW.CONTACT_TYPE
WHEN 'Department' THEN
L_CONTACT_TYPE := 'D';
ELSE
L_CONTACT_TYPE := 'C';
END CASE;
INSERT INTO NOTIFICATIONS VALUES (
P_N_ROW.N_ID,
P_N_ROW.NOTIFICATION_TYPE,
L_NOTIFICATION_DESC,
L_CONTACT_TYPE,
NVL(P_N_ROW.AU_USER_ID, 0),
NVL(P_N_ROW.DEPARTMENT_ID, 0),
APP_GLOBAL_PKG.GET_AUDIT);
END INSERT_AGREEMENT_NOTIFICATION;
END AGREEMENT_NOTIFICATIONS_PKG;
The trigger is configured to pass information to this packet to insert a string. When I try to run the following line of code, I get error ORA-01031:
INSERT INTO V_AGREEMENT_NOTIFICATIONS VALUES (5781, 'Collateral Request', 'Send to', 'Contact', 797, '797T', 0, null);