Difference between revisions of "DBC AFTERDELETE"

From Lianjapedia
Jump to: navigation, search
Line 58: Line 58:
 
[[Category:SQL]]
 
[[Category:SQL]]
 
[[Category:Databases]]
 
[[Category:Databases]]
 +
[[Category:Database Triggers]]

Revision as of 04:23, 15 December 2017

Purpose

Database events are triggered by certain database operations

See Also

ADATABASES(), ALTER TABLE, ADD TABLE, ALTER INDEX, BASE64_DECODE(), BASE64_ENCODE(), CLOSE DATABASES, CLOSE TABLES, COMPILE DATABASE, CREATE DATABASE, CREATE TABLE, CREATE INDEX, CREATE VIEW, DATABASE(), Database Events, DBUSED(), DISPLAY DATABASE, DISPLAY INDEXES, DISPLAY TABLES, DROP DATABASE, DROP INDEX, DROP TABLE, GETENV(), LIST DATABASE, LIST INDEXES, LIST TABLES, OPEN DATABASE, PACK DATABASE, REBUILD DATABASE, REINDEX DATABASE, SET AUTOCATALOG, SET EXCLUSIVE, USE, USERLOG()

Description

The DBC_AFTERDELETE database event is triggered following a delete operation when a database is open and runs dbc_afterdelete.prg (.dbo compiled/runtime) if it exists.

Programs associated with database events should reside in the database's directory. These can be created and modified from the Events tab in the Data Workspace when a database is open.

The following parameters are passed to the dbc_afterdelete program:

Parameter Description
<cDatabase> The database name
<cTable> The table name
<cJSON> Base64 encoded JSON data for the operation. See notes below.

<cJSON>

<cJSON> is populated on the Web and Mobile clients. For the Desktop client, where <cJSON> is empty, the current record is accessible and can be queried using standard Lianja/VFP functions (recno(), field(), fldcount() etc.).

If the JSON data exceeds the maximum command line length (16KB), <cJSON> will contain '@' and the data can be accessed using the JSONDATASTRING() function up to maximum string length (64KB).

For the dbc_afterdelete event, <cJSON> will contain the rowid, e.g.

{"__rowid":19}

Example

//
// Database: dbcdoc
// Event: dbc_afterdelete
//
parameters cDatabase, cTable, cJSON
userlog("====================================")
userlog("After Delete in "+"dbcdoc database")
userlog("Database: " +cDatabase)
userlog("Table: " +cTable)
if ! isserver()
	userlog("Deleted record number: " + etos(recno())
else
	userlog("JSON: " + base64_decode(cJSON))
endif
userlog("End of After Delete")
userlog("====================================")
return .t.