Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Use of triggers
Message
From
07/12/2000 18:28:52
 
 
To
07/12/2000 17:21:44
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00450619
Message ID:
00450652
Views:
40
>>MyTable has 3 fields: cName, cName2 and cNameSearch.
>>cName2 is used for cName change and cNameSearch to optimize search.
>>When cName2 is not empty its lower case value must be copied
>>in cNameSearch otherwise the cName will be. I would like to use trigger
>>update (in the table) for that. But I do not know what enter in the
>>"update trigger" field in the table properties. Someone could show me
>>the way to do a trigger in VFP? Thank you very much.

>You would enter the name of a function, typically a stored procedure in the >table's database. e.g., if your procedure name is UpdateName then put >UpdateName() in the Update trigger box.
>If you need any parameters, make sure those are in there as well. >e.g.,UpdateName(cName, cName2)

Thank you Trey. I done the function in stored procedure of database.
I put the function name and parameters in the update trigger field of
the table. I put a suspend and used debugger to follow the execution.
Because I got an error message "Trigger Failed" but exactly "Cannot
Update Cursor" when the REPLACE command was executing below.
****************************
FUNCTION UpdateSearchField
LPARAMETERS tcTableName, tcField1, tcField2, tcFieldSearch
LOCAL lcNameSearch, llOk, lcOnError, llError

lcOnError=ON("ERROR")
ON ERROR llError=.T.
IF PCOUNT()=4 AND TYPE('tcTableName')="C" AND TYPE('tcField1')="C"
AND TYPE('tcFieldSearch')="C"
IF USED("&tcTableName")
IF TYPE('tcField2')="C"
IF !EMPTY(&tcTableName..&tcField2)
lcNameSearch=LOWER(&tcTableName..&tcField2)
ELSE
lcNameSearch=LOWER(&tcTableName..&tcField1)
ENDIF
ELSE
lcNameSearch=LOWER(&tcTableName..&tcField1)
ENDIF
IF &tcTableName..&tcFieldSearch<>lcNameSearch
IF RLOCK("&tcTableName")
REPLACE &tcTableName..&tcFieldSearch WITH lcNameSearch
IN &tcTableName
UNLOCK IN &tcTableName
llOk=not llError
ENDIF
ENDIF
ENDIF
ENDIF
ON ERROR &lcOnError
RETURN llOk
**************
Is it possible for you to find my problem?
Thank you again.
Marc Levesque
La Prairie, Quebec (CANADA)
marc.levesque@videotron.ca
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform