BeforeModifyView, AfterModifyView

These database events fire when a view is modified in the View Designer.

Usage

PROCEDURE DBC_BeforeModifyView( cViewName )
 
PROCEDURE DBC_AfterModifyView( cViewName, lChanged )

Parameter

Value

Meaning

cViewName

Character

The name of the view being modified.

lChanged

Logical

Indicates whether the view was changed.


Like other before-and-after pairs of events, you can prevent a view from being modified (the View Designer won't appear) by returning .F. in the BeforeModifyView event, while the AfterModifyView event simply fires, notifying you that the view was modified and either changed or not.As discussed in the "Database Events" topic, there's no way to tell what changes a user made, so if that's important, you'll have to save the current view structure in the BeforeModifyView event, or rely on metadata that saves that information somewhere, and then compare the saved information against the view structure in the AfterModifyView event.

Example

* This goes in the stored procedures of a database.
 
PROCEDURE DBC_BeforeModifyView(cViewName)
WAIT WINDOW PROGRAM() + CHR(13) + ;
    'cViewName: ' + cViewName
 
PROCEDURE DBC_AfterModifyView(cViewName, lChanged)
WAIT WINDOW PROGRAM() + CHR(13) + ;
    'cViewName: ' + cViewName + CHR(13) + ;
    'lChanged: ' + TRANSFORM(lChanged)
 
* End of stored procedures.
 
 
* Create a view, and then modify it.
 
OPEN DATABASE TestData
DBSETPROP(DBC(), 'Database', 'DBCEvents', .T.) && Turn on events
CREATE SQL VIEW TestView AS SELECT * FROM Customer
MODIFY VIEW TestView

See Also

BeforeCreateView, BeforeDropView, Create SQL View, Database Events, Modify View


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .