Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DBC, Referential Integrity, and Errors
Message
De
07/03/1997 03:25:37
 
 
À
06/03/1997 17:26:07
Michael Knelsen
Technology Management Corporation
Regina, Saskatchewan, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00023205
Message ID:
00023273
Vues:
25
>>>I have set up Referential Integrity(RI) in between my databases(Update, Delete, and Insert are all Restrict). Now, when I get an error, it goes to my error handler like it suppost to, but, I now have and array called GAERRORS that exists. This one-dimensional array contains 10 rows, of which half I know what they represent. I am assuming that the RI code creates this array, but I can not find anywhere that say's what the values in the array stand for. If anyone knows what the information in this array stands for, please let me know. Thanks in advance.
>>
>>I have no idea what is gaerrors, but basically you could use (within error trap) AERROR() to retrieve error information into array.
>
>Maybe I didn't explain it well enough....gaerrors is being created out of thin air and showing up when I look at the Locals variable through debug window. I have not created this array anywhere. What follows is an example of what is contained in the array
>
>gaerror[1,1] = -1
>gaerror[1,2] = "Delete Restict Rule Violated"
>gaerror[1,3] = ""
>gaerror[1,4] = "temain"
>gaerror[1,5] = "c:\data\vss\t&ev2\code\data\table2.dbf"
>gaerror[1,6] = 1
>gaerror[1,7] = 1
>gaerror[1,8] = "forkey"
>gaerror[1,9] = "c:\data\vss\t&ev2\code\data\tables3.dbf"
>gaerror[1,10] = 1
>gaerror[1,11] = 1
>gaerror[1,12] = "initkey"
>
>Of these, I know what rows 2,4,5,8,9,12 stand for, but the others I am just wondering what they stand for, and if they are important for me to record.

Hello

This is what I have got from M$-support Norway.

How to Use gaErrors[] to Find Out Why a Trigger Failed [foxpro]
ID: Q142284 CREATED: 08-JAN-1996 MODIFIED: 15-JAN-1996
3.00 3.00b
WINDOWS
PUBLIC | kbprg kbcode kbhowto

---------------------------------------------------------------------
The information in this article applies to:

- Microsoft Visual FoxPro for Windows, versions 3.0 and 3.0b
---------------------------------------------------------------------

SUMMARY
=======

A 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 INFORMATION
================

gaErrors[] 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:

Error Number: tnError - ERROR()
Error Message: tcMessage - MESSAGE()
line of code that caused the error: tcCode - MESSAGE(1)
program name in which the error occurred: tcProgram - PROGRAM()

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:

",FORM1.COMMAND1.CLICK,__RI_INSERT_ParentTable,RIERROR".

The gaErrors[] array also holds the following information:

Parent Table's Name - pcParentDBF
current record of the Parent Table when the error occurred - pnParentRec
Parent's Primary Key value at the time of the error - pcParentID
The Field name the Primary Key index is based on - pcParentExpr

The equivalent Child Table's information is also added to gaErrors[]:

Child Table's Name - pcChildDBF
current record of the Child Table when the error occurred - pnChildRec
Child's Primary Key value at the time of the error - pcChildID
The Field name the Primary Key index is based on - pcChildExpr

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:

IF .NOT. TABLEUPDATE(.T.,.T.)
=TABLEREVERT(.T.) &&Revert the change
IF TYPE('gaErrors[1,1]') <> 'L'
=MESSAGEBOX('Trigger Failed - '+gaErrors[1,2],0,;
'Data Entry Error/Trigger Failed')
ENDIF
GO TOP
ENDIF
THISFORM.REFRESH

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:

_SCREEN.SHOW()
DISPLAY MEMORY LIKE gaErrors

Additional reference words: 3.00 3.00b VFoxWin
KBCategory: kbprg kbcode kbhowto
KBSubcategory: FxprgGeneral
Best regards
Niklas Fjellman

E-mail: niklas.fjellman@adb-kontoret.goteborg.se
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform