PRE, POST, POST_NO

The hooks for these methods are available to be executed prior or after the INSERT, UPDATE or DELETE queries. The methods can generate a SQL code depending on which user is connected. The methods are used often in the .mql files, many examples of their use can be found in the /opt/masonsql/htdocs/ directory tree.

Group Name Method Name Arguments Description
PRE_     The PRE methods are called before the main query is executed.
  PRE_INSERT    
    $FIELDS_INSERT Is a hash pointer.
The $FIELDS, $VALUES and $LIST_VALUES are extracted from the $FIELDS_INSERT.
    $DUP_KEY $Params->{'dup_key'}
    $PARAMS A parameters for the prepared query must be added to the \%params
  PRE_UPDATE   The PRE_DELETE, DELETE are also called just before PRE_UPDATE if any of the fields from DELETE_IF_FIELD_EMPTY is to be updated with an empty value.
    $KEY A primary key value.
    $FIELDS_UPDATE Is a hash pointer.
The $UPDATES and $LIST_VALUES are extracted from the $FIELDS_UPDATE.
    $PARAMS A parameters for the prepared query must be added to the \%params
  PRE_DELETE    
    $KEY A primary key value.
    $PARAMS A parameters for the prepared query must be added to the \%params
POST_     The POST methods are called after the main query was executed.
  POST_INSERT    
    $KEY A primary key value.
    $DUP_KEY $Params->{'dup_key'}
    $ROW A contents of a record.
    $FIELDS_INSERT Is a hash pointer.
    $PARAMS A parameters for the prepared query must be added to the \%params
  POST_UPDATE    
    $KEY A primary key value.
    $ROW A contents of a record.
    $FIELDS_UPDATE Is a hash pointer.
    $PARAMS A parameters for the prepared query must be added to the \%params
  POST_DELETE    
    $KEY A primary key value.
    $PARAMS A parameters for the prepared query must be added to the \%params
POST_NO_     The POST_NO methods are called when the main query was not executed.
  POST_NO_INSERT    
    $KEY A primary key value.
    $DUP_KEY $Params->{'dup_key'}
    $ROW A contents of a record.
    $PARAMS A parameters for the prepared query must be added to the \%params
  POST_NO_UPDATE    
    $KEY A primary key value.
    $ROW A contents of a record.
    $PARAMS A parameters for the prepared query must be added to the \%params
  POST_NO_DELETE    
    $KEY A primary key value.
    $PARAMS A parameters for the prepared query must be added to the \%params

Compared to the use of editable views it is easier to manage code, inside the MasonSQL .mql files.
The sql rules that must be used with the editable views are complicated, hard to understand even by DBAs and consequently not practical.
Topic revision: r6 - 22 Apr 2018, GuidoBrugnara
This site is powered by FoswikiCopyright (©) Leader.IT - Italy P.I. IT01434390223 Privacy policy & use of cookies