INSERT, UPDATE, DELETE

Method Name ArgumentsSorted ascending Description Default Contents
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&>');
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) %>;
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) %>;
  $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.
 
  $FIELDS_UPDATE A hash of the field names with their values.  
  $KEY A primary key.  
  $KEY A primary key.  
  $LIST_VALUES An array of values $LIST_VALUES->[n] used during $sth->execute(); The list can be modified.  
  $LIST_VALUES An array of values $LIST_VALUES->[n] used during $sth->execute(); It can be modified.  
  $NEW_KEY A new primary key - if provided.  
  $UPDATES A list of fields to be updated: field1 = ?, field2 = ?, ...  
  $VALUES A list of question marks: ?,?,...  
Topic revision: r8 - 22 Apr 2018, GuidoBrugnara
This site is powered by FoswikiCopyright (©) Leader.IT - Italy P.I. IT01434390223 Privacy policy & use of cookies