Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Insert trigger failed.
Message
 
À
17/12/2003 09:17:17
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00859859
Message ID:
00860659
Vues:
11
Hi Steve,

Have you tried re-working that section of code to somthing like this:
**get the number of valid plays
lnplays=0
SELECT plays
LOCATE     && faster than GO TOP
lnRecNo=RECNO()
COUNT FOR !DELETED() AND plays.gamenum==games.gamenum To lnplays
HTH,
Arriyel

>I have a form with a method called zallownew.
>This method must return true before a new record can be added to the main table in the DE.
>
>intermittenly I am getting this error, usually when the plays table is empty or has only a few records:
> WARNING UNABLE TO COMMIT CHANGES FOR PLAYS-INSERT TRIGGER FAILED.
>
> ERROR #1539 in Zallownew line 9 workarea 0 trigger failed
>
>Line 9 is "GO TOP" zallownew looks like this:
>
*****************************
>** set maximum records in demo mode
>LOCAL lcConfirm, lnplays, lnMaxplays, lnREcno
>lnMaxplays=20
>
>**get the number of valid plays
>lnplays=0
>SELECT plays
>GO top
>lnRecNo=RECNO()
>SCAN FOR !DELETED() AND plays.gamenum==games.gamenum
>	lnplays=lnplays+1
>ENDSCAN
>
>**return serial number mode
>lcConfirm=thisform.zserialconfirm('PLAYS')
>*lcConfirm='FULL' &&Full version test
>SELECT plays
>*GO lnRecNo
>*thisform.Refresh()
>
>DO case
>	CASE lcConfirm=='DEMO'	&&standard demo mode
>		IF lnplays>=lnMaxplays
>			thisform.omessage.warning(PROPER('This demo version has exceeded the allowable number of plays'))
>			m.gostatemanager.openform('utilregister.scx')
>			RETURN .f.	
>		ELSE
>			RETURN .t.
>		endif
>	CASE lcConfirm!='DEMO' AND lcConfirm!='FULL'	&&extended demo mode
>		lnMaxplays=VAL(lcConfirm)
>		IF lnplays>=lnMaxplays
>			thisform.omessage.warning(PROPER('This demo version has exceeded the allowable number of plays'))
>			m.gostatemanager.openform('utilregister.scx')
>			RETURN .f.	
>		ELSE
>			RETURN .t.
>		endif		
>	CASE lcConfirm=='FULL'	&&full mode
>		RETURN .t.
>	OTHERWISE
>		m.gostatemanager.openform('utilregister.scx')
>		RETURN .f.
>endcase
>
>
>The insert trigger is the system created RI:
>
********************************************************************************
>** "Referential integrity insert trigger for" plays
>PROCEDURE __RI_INSERT_plays
>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 ("COMPUSPORTS")
>ENDIF first trigger
>LOCAL lcChildID && child's value to be sought in parent
>LOCAL lcParentWkArea && parentwork area handle returned by riopen
>LOCAL lcChildWkArea && child's work area
>LOCAL lcStartArea
>lcStartArea=select()
>llRetVal=.t.
>lcChildWkArea=SELECT()
>SELECT (lcChildWkArea)
>lcChildID=GAMENUM
>pcChildDBF=dbf(lcChildWkArea)
>pnChildRec=recno(lcChildWkArea)
>pcChildID=lcChildID
>pcChildExpr="GAMENUM"
>lcParentWkArea=riopen("games","gamenum")
>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)
>=rireuse("games",lcParentWkArea)
>IF NOT llRetVal
>  DO rierror with -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
>IF _triggerlevel=1
>  do riend with llRetVal
>ENDIF at the end of the highest trigger level
>SELECT (lcStartArea)
>RETURN llRetVal
>** "End of Referential integrity insert trigger for" plays
>********************************************************************************
Speak using soft and sweet words in case you have to eat them later.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform