Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Nesting error in trigger
Message
De
13/06/2005 02:12:30
 
 
À
12/06/2005 20:29:48
Eugene Kolmakov
Millennium Technologies
Vladivostok, Russie
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01022038
Message ID:
01022674
Vues:
11
>Hi Gregory!
>
>I use such structure for my own reasons. I have a table which stores information about two types of agreements: main agreements and additional agreements belonging to them. They have similar structure so I keep them in one table with the mark indicating if it is a main agreement or additional agreement.
>And I use subclass of a Grid object designed to show information in a tree-form. So I need child records to have some information about parents in order to biuld proper indexes for tree-grid sorting.
>
>The last version of trigger code I tried to use was following:
>
>FUNCTION Update_Index_Tags
>
>IF DogType = 1
>
> lcCurrentAlias = ALLTRIM(ALIAS())
> lcParentID = ALLTRIM(Key)
> lcAgrNum = ALLTRIM(Agreement_Number)
> ldAgrDate = Agreement_Date
> lcOwnerName = ALLTRIM(Owner_Name)
> lcPayerName = ALLTRIM(Payer_Name)
> lcShipName = ALLTRIM(Ship_Name)
> lcAliasName = SYS(2015)
>
> USE Agreements AGAIN IN 0 ALIAS (lcAliasName)
>
> SELECT (lcAliasName)
> Replace Parent_ANum WITH lcAgrNum, Parent_ADate WITH ldAgrDate,;
> Parent_Owner WITH lcOwnerName, Parent_Payer WITH lcPayerName,;
> Parent_Ship WITH lcShipName FOR ALLTRIM(Parent) == lcParentID
> IN lcAliasName)
>
> USE IN (lcAliasName)
>
> IF !EMPTY(lcCurrentAlias)
> SELECT (lcCurrentAlias)
> ENDIF
>
>ENDIF
>
>RETURN .t.
>
>ENDFUNC
>
>And it raises error. According to VFP help:
>
>"A rule or trigger code caused the original cursor, the cursor from which the rule or trigger was fired, to try to evaluate a rule or trigger recursively. This can occur under the following conditions:
>
>Attempting to move the record pointer or change values in the original cursor.
>
>
>Attempting to move the record pointer in the BeforeUpdate event for a CursorAdapter object.
>
>
>Check your rule or trigger code"
>
>What can I do with this?

___________
Eugene,

You could use a view in your grid.

As to the error, you will have to debug the code. I see a missing left parenthesis at the end of the replace statement, maybe a typo

When the error occurs, go into the debugger and find out the statement that caused the error. You can also SUSPEND the function on entry and step through with the debugger.

What the help does not say is that any reference to a non-existing variable/field will give the error as well (maybe replacing a numeric field with char)

Try to declare the variables as local. One trigger may trigger another and may change your variables if you don't.


And watch out for the ALLTRIM in the replace statement. It will not use the index, if any.


Success,
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform