ACCEPT

BeforeCreateOffline, AfterCreateOffline, BeforeDropOffline, AfterDropOffline

These database events fire when a view is taken offline with CreateOffline() or taken back online with DropOffline().

Usage

PROCEDURE DBC_BeforeCreateOffline( cViewName, cPath )   PROCEDURE DBC_AfterCreateOffline( cViewName, cPath )   PROCEDURE DBC_BeforeDropOffline( cViewName )   PROCEDURE DBC_AfterDropOffline( cViewName )

Parameter

Value

Meaning

cViewName

Character

The name of the view.

cPath

Character

The path and name for the table representing the offline view.


The template generated for the BeforeDropOffline and AfterDropOffline events by the Database Properties dialog has a second parameter, cPath. However, this parameter is never passed a value (PCOUNT() is 1 and cPath is always .F.). So, there's really no such parameter. We're pretty sure a copy and paste operation in VFP's source code was the cause of this, since we've done similar things ourselves once or twice.


As is the case with other before-and-after pairs of events, you can prevent a view from being taken offline or back online by returning .F. in the Before events, while the After events simply receive notification that something happened.

One use for BeforeDropOffline is to ensure there aren't any changes in the offline view, since DropOffline() erases the table representing the offline view and any changes in it are lost. The example shows the code for this.

Example

* Prevent a view from being taken online if there are any * changes. This goes in the stored procedures of the database.   PROCEDURE DBC_BeforeDropOffline(cViewName) LOCAL lnSelect, ;     llReturn lnSelect = SELECT() SELECT 0 USE (cViewName) ADMIN EXCLUSIVE llReturn = GETNEXTMODIFIED(0, ALIAS(), .T.) = 0 USE SELECT (lnSelect) RETURN llReturn   * End of stored procedures.     * Test it by creating a view, taking it offline, making a * change, and then trying to take it back online.   CREATE SQL VIEW TestView AS SELECT * FROM Customer SET MULTILOCKS ON CREATEOFFLINE("TestView") USE TestView REPLACE COMPANY WITH "New Company Name" USE   DROPOFFLINE("TestView") llOffline = DBGETPROP("TestView", "View", "Offline") WAIT WINDOW 'TestView is ' + IIF(llOffline, "offline", "online")

See Also

CreateOffline(), Create SQL View, Database Events, DropOffline(), GetNextModified(), Use


View Updates

Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.



Hacker's Guide to Visual FoxPro 7. 0
Hackers Guide to Visual FoxPro 7.0
ISBN: 1930919220
EAN: 2147483647
Year: 2001
Pages: 899

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net