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. |
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 |