dataEvent_record_BeforeDeleteRowWithConcurrentAccess

Function called before deleting a row with concurrent access.

Syntax

PUBLIC FUNCTION dataEvent_record_BeforeDeleteRowWithConcurrentAccess( 
   p_dataT0 record-type)
   RETURNS (INTEGER, STRING, record-type)

The function has one parameter:

  1. p_dataT0. This is a RECORD containing a row of data. It is defined according to the structure of the database table.
It returns values:
  1. An integer specifying the SQLCA.SQLCODE error number. Codes are defined as constants in the libdbappSql and libdbappCore files in the libdbapp library. If the code is a negative number, an SQL error has occurred. The errors that are relevant in this function are shown in the table.
    Table 1. SQLCA.SQLCODE
    Description Constant Value
    Success ERROR_SUCCESS 0
    Failure ERROR_FAILURE -1
    Concurrent access failure ERROR_CONCURRENT_ACCESS_FAILURE -2
    Concurrent access not found ERROR_CONCURRENT_ACCESS_NOTFOUND -3
  2. A string is returned with the SQLERRMESSAGE error message.
  3. record-type. This is a RECORD type defined according to the structure of the database table.

Usage

When you select the Before Delete Row With ConcurrentAccess property for the creation of the event, a function shell is created. Enter your code in the function.

This function is called before deleting a row in a database where access is concurrent and where a table can be locked. Use this function to perform some operation, typically a SQL operation, on another table. For example, you could write the row of data to a backup table before the row is deleted. This event is called before deleting a row in the database .

Example: BeforeDeleteRowWithConcurrentAccess

This example uses the Before Delete Row code event for the Account table in the OfficeStore demo.

The row of data referenced by the variable p_dataT0 is written to a backup table. It is assumed that you have created the backup table for account before saving the row to it.

PUBLIC FUNCTION dataEvent_recAccount_BeforeDeleteRowWithConcurrentAccess(p_dataT0 RECORD LIKE account.*)
    RETURNS (INTEGER, STRING, RECORD LIKE account.*)

    DEFINE errNo INTEGER
    DEFINE errMsg STRING

    DISPLAY "dataEvent_recAccount_BeforeDeleteRowWithConcurrentAccess (Row scope) is raised"
    TRY
        INSERT INTO account_backup VALUES (p_dataT0.*)
    CATCH
        DISPLAY "SQL ERROR: ", SQLCA.SQLCODE
        LET errNo = ERROR_FAILURE
        LET errMsg = " - BeforeDeleteRowWithConcurrentAccess failed to insert row in backup "
    END TRY
    DISPLAY "dataEvent_recAccount_BeforeDeleteRowWithConcurrentAccess (Row scope) is exited"

    RETURN errNo, errMsg, p_dataT0.*
END FUNCTION