QDBRTVFD - Retrieve Database File Description
D wFDSize ds
D wFDSize1 9b 0
D wFDSize2 9b 0
D Qdb_Qdbfh ds
d Qdbfyret 9b 0
d Qdbfyavl 9b 0
d Qdbfhflg 2
d Reserved_7 4
d Qdbflbnum 4b 0
d Qdbfknum 4b 0
d Qdbfkmxl 4b 0
d Qdbfkflg 1
d Qdbfkfdm 1
d Reserved_10 8
d Qdbfhaut 10
d Qdbfhupl 1
d Qdbfhmxm 4b 0
d Qdbfwtfi 4b 0
d Qdbfhfrt 4b 0
d Qdbfhmnum 4b 0
d Reserved_11 9
d Qdbfbrwt 4b 0
d Qaaf 1
d Qdbffmtnum 4b 0
d Qdbfhfl2 2
d Qdbfvrm 4b 0
d Qaaf2 2
d Qdbfhcrt 13
d Reserved_18 2
d qdbfhtxt 50
d Reserved_19 13
d Qdbfsrcf 10
d Qdbfsrcm 10
d Qdbfsrcl 10
d Qdbfkrcv 1
d Reserved_20 23
d Qdbftcid 5u 0
d Qdbfasp 2
d Reserved_21 1
d Qdbfmxfnum 4b 0
d Reserved_22 76
d Qdbfodic 9b 0
d Reserved_23 14
d Qdbffigl 4b 0
d Qdbfmxrl 4b 0
d Reserved_24 8
d Qdbfgkct 4b 0
d Qdbfos 9b 0
d Reserved_25 8
d Qdbfocs 9b 0
d Reserved_26 4
d Qdbfpact 2
d Qdbfhrls 6
d Reserved_27 20
d Qdbpfof 9b 0
d Qdblfof 9b 0
d Qdbfnlsb 1
d Qdbflang 3
d Qdbfcnty 2
d Qdbfjorn 9b 0
d Reserved_28 18
D* Physical File Attributes
D pQdbpf s *
D Qdb_Qdbpf ds based(pQdbpf)
D qdbfpAlc 2
D qdbfcMPs 1
d Reserved_29 8
D qdbpRNum 9b 0
D qdbfpRI 4b 0
D qdbRINum 4b 0
D qdbfORID 9b 0
D qdbBits33 1
D qdbfOTrg 9b 0 Offset to qdbftrg
D qdbfTrgN 4b 0 No of triggers
D qdbfOFCS 9b 0
D qdbfCstN 9b 0
D qdbfODL 9b 0
D Reserved_32 6
D pQdbftrg s *
D Qdb_Qdbftrg ds based(pQdbftrg)
D qdbfTrgT 1
D qdbfTrgE 1
D qdbfTPgm 10
D qdbfTPLb 10
D qdbfTUpd 1
D qdbBits69 1
D Reserved_201 24
D pFD s *
D wFD s 1000 dim(1000) based(pFD)
D wCurTrg s 4b 0
** Open file description
p OpenFILD0100 b export
d pi
D xFile 20 const
D xRcdFmt 10 const
D wErr s 8 inz(x'0000000000000000')
D wFDLen s 9b 0
D wFile s 20
D wFmt s 8 inz('FILD0100')
D wFmtType s 10 inz('*INT')
D wi s 5 0
D wOvr s 1 inz('0')
D wRcdFmt s 10
D wSystem s 10 inz('*LCL')
C eval wFile = xFile
C eval wRcdFmt = xRcdFmt
c* get size needed
C call 'QDBRTVFD'
C parm wFDSize
C parm 8 wFDLen
C parm wRtnFile
C parm wFmt
C parm wFile
C parm wRcdFmt
C parm wOvr
C parm wSystem
C parm wFmtType
C parm wErr
C eval pFD = malloc(wFDSize2)
C call 'QDBRTVFD'
C parm wFD
C parm wFDSize2 wFDLen
C parm wRtnFile
C parm wFmt
C parm wFile
C parm wRcdFmt
C parm wOvr
C parm wSystem
C parm wFmtType
C parm wErr
C movea wFD Qdb_Qdbfh
C return
p OpenFILD0100 e
** Close file description
p CloseFILD0100 b export
C dealloc pFD
C return
p CloseFILD0100 e
** Get Number of Triggers
p GetNbrTrg b export
d pi like(qdbfTrgN)
C eval pQdbpf = pFD + Qdbpfof
C return qdbfTrgN
P GetNbrTrg e
** Get First Trigger
p GetFirstTrg b export
d pi 1
C eval pQdbpf = pFD + Qdbpfof
C eval wCurTrg = 1
C if qdbfOTrg > 0
C eval pQdbfTrg = pFD + qdbfOTrg
C return '0'
C else
C return '1'
C endif
p GetFirstTrg e
** Get Next Trigger
p GetNextTrg b export
d pi 1
C if wCurTrg < qdbfTrgN
C eval wCurTrg = wCurTrg + 1
C eval pQdbfTrg = pQdbfTrg + %size(qdb_qdbfTrg)
C return '0'
C else
C return '1'
C endif
p GetNextTrg e
** Get Trigger Time
p GetTrgTime b export
d pi 10
C select
C when qdbfTrgT = '1'
C return 'AFTER'
C when qdbfTrgT = '2'
C return 'BEFORE'
C other
C return qdbfTrgT
C endsl
p GetTrgTime e
** Get Trigger Event
p GetTrgEvent b export
d pi 10
C select
C when qdbfTrgE = '1'
C return 'INSERT'
C when qdbfTrgE = '2'
C return 'DELETE'
C when qdbfTrgE = '3'
C return 'UPDATE'
C other
C return qdbfTrgE
C endsl
p GetTrgEvent e
** Get Trigger Program
p GetTrgPgm b export
d pi like (qdbfTPgm)
C return qdbfTPgm
p GetTrgPgm e
** Get Trigger Program Library
p GetTrgPgmLib b export
d pi like (qdbftplb)
C return qdbfTPLb
p GetTrgPgmLib e
** Get Trigger Update Condition
p GetTrgUpdCond b export
d pi 10
C select
C when qdbfTUpd = '1'
C return 'ALWAYS'
C when qdbfTUpd = '2'
C return 'CHANGE'
C other
C return qdbfTUpd
C endsl
p GetTrgUpdCond e
(malloc is defined like this:)
** Allocate memory
p malloc b export
d pi *
d xSize 9b 0 const
d pPtr s *
C alloc xSize pPtr
C return pPtr
p malloc e
Example Usage (pseudo):
OpenFilD0100
eval *in99 = GetFirstTrg
dow *in99 = *off
eval fld1 = GetTrgPgm
...
eval *in99 = GetNextTrg
enddo
CloseFilD0100
阅读(609) | 评论(0) | 转发(0) |