BeforeCreateView, AfterCreateView

These database events fire when a view is created.

Usage

PROCEDURE DBC_BeforeCreateView( cViewName )
 
PROCEDURE DBC_AfterCreateView( cViewName, lRemote )

Parameter

Value

Meaning

cViewName

Character

The name of the view being created.

lRemote

.T.

The view is a remote view.

.F.

The view is a local view.


We can't understand why BeforeCreateView doesn't have an lRemote parameter. Whether you create the view programmatically using CREATE SQL VIEW or visually using the View Designer, by the time BeforeCreateView fires, you've told VFP whether you're creating a remote view or a local one.


As with other before-and-after pairs of events, you can prevent a view from being created by returning .F. in the BeforeCreateView event. The AfterCreateView event simply receives notification that a view was created.

Example

PROCEDURE DBC_BeforeCreateView(cViewName)
WAIT WINDOW PROGRAM() + CHR(13) + cViewName
 
* Ensure that view names follow the naming convention of using
* "LV_" as a prefix for local views and "RV_" for remote views.
 
PROCEDURE DBC_AfterCreateView(cViewName, lRemote)
IF (lRemote AND LEFT(cViewName, 3) <> "RV_") OR ;
    (NOT lRemote AND LEFT(cViewName, 3) <> "LV_")
    MESSAGEBOX(cViewName + " doesn't follow the corporate " + ;
        "naming convention for views.")
ENDIF

See Also

Create SQL View, Database Events


Back to Table of Contents

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