INSERT, UPDATE, DELETE

Method NameSorted descending Arguments Description Default Contents
UPDATE   Update an existing record.
The method is called from Array2UpdateSql() function where it is handled similarly to the INSERT method. Prior to the insertion it is checked whether the DELETE_IF_FIELD_EMPTY method must be handled.
update <&SELF:SCHEMA_FROM&> set <%$UPDATES%> where <&SELF:KEY&> = <% encodeSql($KEY) %>;
INSERT   Insert a new record.
The metod is called from Array2UpdateSql() function which uses it with the Perl DBI. The Array2UpdateSql() first makes a prepared query then it executes it with the @{$LIST_VALUES} parameters.
insert into <&SELF:SCHEMA_FROM&> (<%$FIELDS%>) values (<%$VALUES%>);
If the key is not provided, it is retrieved from the sequence:
select currval('<&SELF:SERIAL_SEQ&>');
DELETE   Delete a record.
The method is called from Array2DeleteSql() function, from the delete method and also during handling of the UPDATE query.
Examples of the overloaded DELETE method can be found in:
/opt/masonsql/htdocs/data/public/anagrafiche.mql ,
/opt/masonsql/htdocs/data/public/funzioni.mql files.
delete from <&SELF:SCHEMA_FROM&> where <&SELF:KEY&> = <% encodeSql($KEY) %>;
  $NEW_KEY A new primary key - if provided.  
  $FIELDS List of field names: field1, field2, ...  
  $FIELDS_INSERT A hash of the field names with their values.
The $FIELDS, $VALUES and $LIST_VALUES are extracted from the $FIELDS_INSERT.
 
  $VALUES A list of question marks: ?,?,...  
  $LIST_VALUES An array of values $LIST_VALUES->[n] used during $sth->execute(); The list can be modified.  
  $UPDATES A list of fields to be updated: field1 = ?, field2 = ?, ...  
  $FIELDS_UPDATE A hash of the field names with their values.  
  $LIST_VALUES An array of values $LIST_VALUES->[n] used during $sth->execute(); It can be modified.  
  $KEY A primary key.  
  $KEY A primary key.  
Topic revision: r8 - 22 Apr 2018, GuidoBrugnara
This site is powered by FoswikiCopyright (©) Leader.IT - Italy P.I. IT01434390223 Privacy policy & use of cookies