VFP中子表与父表存储过程中参照完整性问题,求助
以下是本人正在做的一个关于试卷系统的参照完整性代码,出现问题是方案内容部分触发器无法触发,查相关资料表示是参照完整性问题,然而我不知道具体是哪个部分出现问题,求助希望有大神可以帮忙解决procedure __RI_UPDATE_方案内容 &&方案内容更新时是试卷方案子表,设置了级联,标记为方案编号
** "Referential integrity update trigger for" 方案内容
LOCAL llRetVal
llRetVal = .t.
PRIVATE pcParentDBF,pnParentRec,pcChildDBF,pnChildRec,pcParentID,pcChildID
PRIVATE pcParentExpr,pcChildExpr
STORE "" TO pcParentDBF,pcChildDBF,pcParentID,pcChildID,pcParentExpr,pcChildExpr
STORE 0 TO pnParentRec,pnChildRec
IF _triggerlevel=1
BEGIN TRANSACTION
PRIVATE pcRIcursors,pcRIwkareas,pcRIolderror,pnerror,;
pcOldDele,pcOldExact,pcOldTalk,pcOldCompat,PcOldDBC
pcOldTalk=SET("TALK")
SET TALK OFF
pcOldDele=SET("DELETED")
pcOldExact=SET("EXACT")
pcOldCompat=SET("COMPATIBLE")
SET COMPATIBLE OFF
SET DELETED ON
SET EXACT OFF
pcRIcursors=""
pcRIwkareas=""
pcRIolderror=ON("error")
pnerror=0
ON ERROR pnerror=rierror(ERROR(),message(),message(1),program())
IF TYPE('gaErrors(1)')<>"U"
release gaErrors
ENDIF
PUBLIC gaErrors(1,12)
pcOldDBC=DBC()
SET DATA TO ("试卷生成系统")
ENDIF first trigger
LOCAL lcParentID && parent's value to be sought in child
LOCAL lcOldParentID && previous parent id value
LOCAL lcChildWkArea && child work area handle returned by riopen
LOCAL lcChildID && child's value to be sought in parent
LOCAL lcOldChildID && old child id value
LOCAL lcParentWkArea && parentwork area handle returned by riopen
LOCAL lcStartArea
lcStartArea=select()
llRetVal=.t.
lcChildWkArea=select()
IF _triggerlevel=1 or type("pccascadeparent")#"C" or (NOT pccascadeparent=="试卷方案")
SELECT (lcChildWkArea)
lcChildID=方案编号
lcOldChildID=oldval("方案编号")
pcChildDBF=dbf(lcChildWkArea)
pnChildRec=recno(lcChildWkArea)
pcChildID=lcOldChildID
pcChildExpr="方案编号"
if isnull(lcChildID) or isnull(lcOldChildID) or lcChildID <> lcOldChildID
lcParentWkArea=riopen("试卷方案","方案编号")
IF lcParentWkArea<=0
IF _triggerlevel=1
DO riend WITH .F.
ENDIF at the end of the highest trigger level
SELECT (lcStartArea)
RETURN .F.
ENDIF not able to open the child work area
pcParentDBF=dbf(lcParentWkArea)
llRetVal=SEEK(lcChildID,lcParentWkArea)
pnParentRec=recno(lcParentWkArea)
if llRetVal and not (isrlocked(pnParentRec, lcParentWkArea) or ;
isflocked(lcParentWkArea))
if rlock(lcParentWkArea)
unlock record pnParentRec in lcParentWkArea
else
=rireuse("tparen",lcParentWkArea)
pnError = rierror(-1,"Insert restrict rule violated.","","")
IF _triggerlevel=1
DO riend WITH llRetVal
ENDIF at the end of the highest trigger level
SELECT (lcStartArea)
RETURN llRetVal
endif
endif
=rireuse("试卷方案",lcParentWkArea)
IF NOT llRetVal
pnError = rierror(-1,"Insert restrict rule violated.","","")
IF _triggerlevel=1
DO riend WITH llRetVal
ENDIF at the end of the highest trigger level
SELECT (lcStartArea)
RETURN llRetVal
ENDIF no parent
ENDIF this value was changed
ENDIF not part of a cascade from "试卷方案"
IF _triggerlevel=1 or type("pccascadeparent")#"C" or (NOT pccascadeparent=="试题")
SELECT (lcChildWkArea)
lcChildID=试题编号
lcOldChildID=oldval("试题编号")
pcChildDBF=dbf(lcChildWkArea)
pnChildRec=recno(lcChildWkArea)
pcChildID=lcOldChildID
pcChildExpr="试题编号"
if isnull(lcChildID) or isnull(lcOldChildID) or lcChildID <> lcOldChildID
lcParentWkArea=riopen("试题","试题编号")
IF lcParentWkArea<=0
IF _triggerlevel=1
DO riend WITH .F.
ENDIF at the end of the highest trigger level
SELECT (lcStartArea)
RETURN .F.
ENDIF not able to open the child work area
pcParentDBF=dbf(lcParentWkArea)
llRetVal=SEEK(lcChildID,lcParentWkArea)
pnParentRec=recno(lcParentWkArea)
if llRetVal and not (isrlocked(pnParentRec, lcParentWkArea) or ;
isflocked(lcParentWkArea))
if rlock(lcParentWkArea)
unlock record pnParentRec in lcParentWkArea
else
=rireuse("tparen",lcParentWkArea)
pnError = rierror(-1,"Insert restrict rule violated.","","")
IF _triggerlevel=1
DO riend WITH llRetVal
ENDIF at the end of the highest trigger level
SELECT (lcStartArea)
RETURN llRetVal
endif
endif
=rireuse("试题",lcParentWkArea)
IF NOT llRetVal
pnError = rierror(-1,"Insert restrict rule violated.","","")
IF _triggerlevel=1
DO riend WITH llRetVal
ENDIF at the end of the highest trigger level
SELECT (lcStartArea)
RETURN llRetVal
ENDIF no parent
ENDIF this value was changed
ENDIF not part of a cascade from "试题"
lcParentWkArea=lcChildWkArea
IF _triggerlevel=1
do riend with llRetVal
ENDIF at the end of the highest trigger level
SELECT (lcStartArea)
RETURN llRetVal