HOWTO: Use gaErrors[] to Find Out Why a Trigger FailedID: Q142284 The information in this article applies to:
SUMMARYA trigger fails when its expression or function returns False. When this occurs the "Trigger Failed" error message appears. However, this does not explain why it failed. The Referential Integrity Builder code is no different in this respect. However, the RI Builder does provide a means of finding out exactly why it did fail. This is done through the Public array gaErrors[].
MORE INFORMATIONgaErrors[] is a public array defined by the Trigger code created by the RI Builder. The RI Builder also creates its own ON ERROR routine. When an error occurs, the Trigger's RIERROR routine is called. Look in the Stored Procedures of a Database where the RI Builder has been run, this is where the RIERROR routine can be found. The RIERROR routine is passed four arguments:
The first three are stored into the gaErrors[] array, in columns one
through three. The fourth column does not solely hold tcProgram; it holds
the Program Chain from which the error occurred. For example, it may
contain a string like this one:
The gaErrors[] array also holds the following information:
The equivalent Child Table's information is also added to gaErrors[]:
Use this information within a custom ON ERROR routine to allow an
application to better handle failed triggers and present users with
better choices to resolve the conflict. The code in a "SAVE" button where
the triggers would be invoked may look something like this:
The array gaErrors[] can be seen by setting up some Referential Integrity
Rules with the RI Builder and then performing some operation on those
tables that would violate the rules. After the operation fails, type the
following commands in the Command window:
Additional query words:
|
Last Reviewed: October 29, 1998 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |