Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: HowTo: Trigger for Change- Logging
Andreas Mosmann wrote:
> DA Morgan schrieb am 15.09.2005 in <1126795191.588721_at_yasure>:
>
>> I don't know what you expect of this group but I had an extremely >> hard time understanding what you are asking and am quite sure that >> I still don't know.
>>> [1] Oracle 9.2.0.4, Windows
>>> [2] TBChangeLog >>> CLOGID CHAR 38 --primary key >>> CLOGTIME DATE 7 --time when logging happend >>> CLOGIDUSER CHAR 38 --internal- user
>>> CDATAID CHAR 38 --primary key of record >>> CDATAFIELDS CLOB 4000 --XML- coded Changes
>>> [3] >>> TRIGGER DELETESAMPLE >>> BEFORE DELETE >>> ON SAMPLESCHAME.SAMPLETABLE >>> FOR EACH ROW >>> >>> declare >>> lvsFields varchar2(4000); >>> >>> begin >>> lvsFields := ''; >>> lvsFields:= >>> PChangeLog.EncodeXML('CID',:old.CID,NULL)|| >>> -- some more columns >>> PChangeLog.EncodeXML('CBEMERKUNGEN',:old.CBEMERKUNGEN,NULL) ;
>>> if lvsFields is not null then >>> if lvsFields is not null then >>> >>> lvsFields:='<Spalten>'||chr(13)||lvsFields||'</Spalten>'||chr(13); >>> end if; >>> >>> -- for different projects the columns can differ >>> -- how to get information about application? >>> insert into TBCHANGELOG( >>> clogid, >>> clogtime,
>>> cdataid, >>> cdatafields >>> )values( >>> NewGUID(), >>> sysdate,
>>> :old.cid, >>> lvsProgram >>> ); >>> end if; >>> end;
>>> My questions >>> How to get information about some SessionParameters like >>> V$SESSION.PROGRAM >>> (inside the Trigger the view v_$session and the synonym v$session >>> cant be used, as I tried) >> >> There is nothing that prevents a trigger from querying a view. You >> provided no version information and no error messages. I think you >> need to repost your question and provide a sample trigger that is >> the simplest case that demonstrates the issue.
>>> How can the application store data to a session? Is there only the >>> possibility to use a table or ist there some invert- feature to >>> sys_context() like set_sys_context('APPLICATION_USER','MOSMANN');
>>> What do you thing in General about that?
>>> We decided in the actual case only to collect updates and deletes, >>> and only to store old values, because there are many inserts a day >>> but nearly no updates and deletes (delete must save all columns). Do >>> you think it is enough?
>>> Is it better to use a before or an after- Trigger? >>> What happens if you f.e. use an after- trigger and the before- >>> trigger raises an exception?
>> Sorry I couldn't be more helpful.
Not angered ... confused.
The error you are getting is very specific and clear. You do not have the required privilege on v_$session.
If your access is granted via a role that is insufficient. You must grant explicitly for PL/SQL.
-- Daniel A. Morgan http://www.psoug.org damorgan_at_x.washington.edu (replace x with u to respond)Received on Thu Sep 15 2005 - 14:01:08 CDT