raj28
asked on
trigger on source physical file
Hello friends,
I have read somwhere that it is possible to write trigger on source physical file .
if it is ..then is it possible to write before delete of any member of source physical file i want to take backup of that member in other library ?? how can i write trigger and
how can i backup that member before deletion
(option 4 ) ??
thanks n waiting..
I have read somwhere that it is possible to write trigger on source physical file .
if it is ..then is it possible to write before delete of any member of source physical file i want to take backup of that member in other library ?? how can i write trigger and
how can i backup that member before deletion
(option 4 ) ??
thanks n waiting..
ASKER
Hi daveslater,
I have tried using the following code but it's not working . I have written a before delete trigger on srcpf (srcfile) in which i'm calling rpgle pgm(delpgmrpg ) . I also set a breakpoint in rpgle pgm but it doesn't stop when i'm deleting using option 4.
I have written rpglr pgm like this -
D Buffer DS 32767
D TrgEvent 31 31
D TrgTime 32 32
D OldOff 49 52B 0
D OldLen 53 56B 0
D NewOff 65 68B 0
D NewLen 69 72B 0
* Total Buffer length
D BufLen DS
D Leng 1 4B 0
D Start s 5P 0
D filen E DS EXTNAME(SRCFILE)
*------------------------- ---------- ---------- ---------- ---------
C *entry Plist
C Buffer Parm Buffer
C BufLen Parm BufLen
*
C Select
C When TrgEvent = '2'
C Exsr CheckDelete
C Endsl
*
c call 'DELPGMCL'
c parm filen
c
C Return
*
C CheckDelete Begsr
C Exsr GetOldFields
C Endsr
*
C GetOldFields Begsr
* "Before" image
C Eval Start = OldOff + 1
C Eval filen = %subst(Buffer:Start:OldLen )
*
C Endsr
The code in CL pgm (delpgmcl) is like this -
PGM (&FILENAME)
DCL VAR(&FILENAME) TYPE(*CHAR) LEN(10)
CPYSRCF FROMFILE(RAJLIB/SRCFILE) +
TOFILE(PARAGLIB/QCLSRC) FROMMBR(&FILENAME)
ENDPGM
waiting ....
I have tried using the following code but it's not working . I have written a before delete trigger on srcpf (srcfile) in which i'm calling rpgle pgm(delpgmrpg ) . I also set a breakpoint in rpgle pgm but it doesn't stop when i'm deleting using option 4.
I have written rpglr pgm like this -
D Buffer DS 32767
D TrgEvent 31 31
D TrgTime 32 32
D OldOff 49 52B 0
D OldLen 53 56B 0
D NewOff 65 68B 0
D NewLen 69 72B 0
* Total Buffer length
D BufLen DS
D Leng 1 4B 0
D Start s 5P 0
D filen E DS EXTNAME(SRCFILE)
*-------------------------
C *entry Plist
C Buffer Parm Buffer
C BufLen Parm BufLen
*
C Select
C When TrgEvent = '2'
C Exsr CheckDelete
C Endsl
*
c call 'DELPGMCL'
c parm filen
c
C Return
*
C CheckDelete Begsr
C Exsr GetOldFields
C Endsr
*
C GetOldFields Begsr
* "Before" image
C Eval Start = OldOff + 1
C Eval filen = %subst(Buffer:Start:OldLen
*
C Endsr
The code in CL pgm (delpgmcl) is like this -
PGM (&FILENAME)
DCL VAR(&FILENAME) TYPE(*CHAR) LEN(10)
CPYSRCF FROMFILE(RAJLIB/SRCFILE) +
TOFILE(PARAGLIB/QCLSRC) FROMMBR(&FILENAME)
ENDPGM
waiting ....
Hi
for that what you need is the QIBM_QZDA_INIT format ZDAI0100 exit point
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/index.htm?info/rzaik/rzaik719.htm
Dave
for that what you need is the QIBM_QZDA_INIT format ZDAI0100 exit point
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/index.htm?info/rzaik/rzaik719.htm
Dave
Here is a bit more info on the exit point
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/index.htm?info/rzaii/rzaiimstexdb.HTM
Dave
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/index.htm?info/rzaii/rzaiimstexdb.HTM
Dave
ASKER
hello daveslater,
I couldn't understood how ir works in my program ..(i.e how can i debug that rpgle pgm using this )
pls explain me in detail ( steps )..
thanks n waiting
I couldn't understood how ir works in my program ..(i.e how can i debug that rpgle pgm using this )
pls explain me in detail ( steps )..
thanks n waiting
Hi Raj
The above program will not work as an exit point program. I will generate an example later on today and post it.
Regards
Dave
The above program will not work as an exit point program. I will generate an example later on today and post it.
Regards
Dave
raj28:
You'll probably have a problem using a trigger program because they react at a record level. If you open a member in SEU, make a change to one source line, then save the member, every single source record is deleted and every line is rewritten to the member... except... SEU doesn't do a record delete; it does a clear-member operation and that's not allowed when the file has a *DELETE trigger. Good thing, too, because a *DELETE trigger would fire for every individual source line.
I imagine most source editors work similarly, though I haven't looked. They load the entire member and rewrite the entire member which generates the clear-member.
I'm not really sure what you need. There are a few after-the-fact notifications such as audit journal entries, but they arrive too late. By the time any program reacts, the member is already cleared -- gone.
I suspect what you need is source control -- apply proper authorities/security to your source and disallow deletions (source changes) except through controlled interfaces. The interfaces will be in charge of automated backups.
What OS/400 VRM?
Tom
You'll probably have a problem using a trigger program because they react at a record level. If you open a member in SEU, make a change to one source line, then save the member, every single source record is deleted and every line is rewritten to the member... except... SEU doesn't do a record delete; it does a clear-member operation and that's not allowed when the file has a *DELETE trigger. Good thing, too, because a *DELETE trigger would fire for every individual source line.
I imagine most source editors work similarly, though I haven't looked. They load the entire member and rewrite the entire member which generates the clear-member.
I'm not really sure what you need. There are a few after-the-fact notifications such as audit journal entries, but they arrive too late. By the time any program reacts, the member is already cleared -- gone.
I suspect what you need is source control -- apply proper authorities/security to your source and disallow deletions (source changes) except through controlled interfaces. The interfaces will be in charge of automated backups.
What OS/400 VRM?
Tom
ASKER
Hi tliotta ,
Do u mean that *DELETE trigger on source physical file will not work in my case ?? our version is V4R4 .
Do u mean that *DELETE trigger on source physical file will not work in my case ?? our version is V4R4 .
Hi Raj28, Tom
I generated an exit point program on the
QIBM_QZDA_NDB1 format ZDAD0100
I thought this would work but when I came to try it - nothing. Bang goes my idea.
Dave
I generated an exit point program on the
QIBM_QZDA_NDB1 format ZDAD0100
I thought this would work but when I came to try it - nothing. Bang goes my idea.
Dave
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi tliotta,
I also agree with you. Thnaks for your responses .
I also agree with you. Thnaks for your responses .
you use the following command to add the trigger to thev data base
ADDPFTRG FILE(DSLIBEE/QRPGLESRC) TRGTIME(*BEFORE) TRGEVENT(*INSERT) PGM(DSLIBEE/SRCTRG)
and the program looks somthing like
h
**************************
** **
** Function: Program call via OS/400 on any data base activity **
** relating to file plp04U. Tis program is run **
** prior to the databse beng updated. **
** **
** Use the ADDPFTRG or RMVPFTRG to attach this **
** program to the database. **
** **
** **
**************************
D src E DS EXTNAME(QRPGLESRC)
**************************
D PARM1 DS
* File name
D FNAME 1 10
* Library name
D LNAME 11 20
* Member name
D MNAME 21 30
* Trigger event 1=Insert 2=delete 3=change
D TEVEN 31 31
* Trigger time 1=after 2=before
D TTIME 32 32
* Commit lock level
D CMTLCK 33 33
* Reserved
D FILL1 34 36
* CCSID
D CCSID 37 40B 0
* Reserved
D FILL2 41 48
* Offset to the original record
D OLDOFF 49 52B 0
* Length of the original record
D OLDLEN 53 56B 0
* Offset to the original record null byte map
D ONOFF 57 60B 0
0051.00 * Length of the null byte map
0052.00 D NNLEN 77 80B 0
0053.00 * MAXLEN
0054.00 D MAXLEN 8000 8000
0055.00 **************************
0056.00 D PARM2 DS
0057.00 D LENG 1 4B 0
0064.00 **************************
0065.00 C *ENTRY PLIST
0066.00 C PARM PARM1
0067.00 C PARM PARM2
0068.00 C EVAL SRC =%SUBST(parm1:OLDOFF+1:OLD
0069.00 C EVAL *INLR=*ON
0070.00 C RETURN
This will log all records that are added to the source file, there is an after image
0068.00 C EVAL SRC =%SUBST(parm1:NEWOFF+1:NEW
Dave