Oracle trigger: Declare global variable?

"YOU AND THE ART OF ONLINE DATING" is the only product on the market that will take you step-by-step through the process of online dating, provide you with the resources to help ensure success. Get it now!

Declare v_array in a package if you want to make it global (to a session -- each session will have its own copy of the variable). CREATE OR REPLACE PACKAGE my_global_pkg IS TYPE arr IS TABLE OF VARCHAR2(32) INDEX BY PLS_INTEGER; g_array arr; END my_global_pkg; CREATE OR REPLACE TRIGGER EMPLOYEE_TRG AFTER INSERT OR DELETE OR UPDATE ON EMPLOYEE FOR EACH ROW BEGIN IF UPDATING THEN DBMS_OUTPUT. PUT_LINE('NEW DATA: ' ||:new.NAME ||', OLD DATA: '||:old.

NAME); DBMS_OUTPUT. PUT_LINE('ID: ' || :new. P_ID); my_global_pkg.

G_array(:new. P_ID) := :new.NAME; DBMS_OUTPUT. PUT_LINE('COUNTER: ' || my_global_pkg.

G_array. COUNT); END IF; END; For Multi-session global variables, use relational tables (with appropriate multi-user locking).

You declare the array inside the trigger. So it isn't global, but local. Everytime your trigger runs, you get a new array.

You add one item, display its count, and release it again. The count shows 1, so that works. Your code is working fine, although it's useless.

:) What did you mean it to do? No wait, the count belongs to a different array. You put an item in a local array, and display the count of another (global?

) array. No wonder it won't work. I think you're modifying the wrong array.

Declare v_array in a package if you want to make it global (to a session -- each session will have its own copy of the variable).

You declare the array inside the trigger. So it isn't global, but local. Everytime your trigger runs, you get a new array.

You add one item, display its count, and release it again. The count shows 1, so that works.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions