DBMS Library Component

The dbms_library.comp provides database interface. Some of its methods are also used by frame.html.
Its less complex methods are intended to be used as a constants or as a hooks for customization in .mql files.
Available subroutines are defined inside <%once> block. The subroutines are helpful for further customization.

Methods and subroutines:

Authorization Methods and Subroutines

[SQL injection check] Queries generated by the GUI are controlled by the server.

Subroutines

Subroutine Name Parameter Name Valid Input Description
check_where_clause()      
Permission()      
  $permission_group   Group to which user must be authorized.
  $table   Name of the table for which the permission is being checked.
ReportMethod()     The subroutine checks the $report parameter for suffix and returns which report utility is used.
  $report report_name.odt,
report_name.pdf,
report_name.rep
Report name. If the $report is not defined or there is no suffix the utility is chosen based on value of the DefaultReportEngine variable from the Apache config file.
CheckIfReportExists()     If the report method is odt or pdf the subroutine checks if the report name can be found in public.odt_reports table.
If the report method is rep the subroutine uses FindReportmanFile() to search and validate the found report file. The subroutine returns 1 on success and 0 on failure.
  $table   Name of the table for which the permission is being checked.

The check_where_clause() subroutine parses the query and verifies that only authorized keywords, fields and operators are used. Here are the methods that change its behavior:

Methods

Method Name Description Default Contents
PERMISSION Is used for overriding of the default PERMISSION_BY_PROFILE. <%method PERMISSION><&SELF:PERMISSION_BY_PROFILE&></%method>
PERMISSION_BY_PROFILE It reads permissions for the record-set manipulation based on the user's profile. It is used often to return user's permissions of the current FUNZIONE. Possible return values:
INSERT, SELECT, UPDATE, DELETE, ...;
Empty return is equivalent to have no permissions allowed;
* is equivalent to having all permissions.
AUTHORIZED_FUNCTIONS A list of authorized functions. Used to check queries from browser. Empty.
AUTHORIZED_KEYWORDS A list of authorized keywords. Used to check queries from browser. Default keywords are AND, OR, NOT, IS, NULL.
AUTHORIZED_OPERATORS A list of authorized operators. Used to check queries from browser. Default authorized operators are <=, >=, =, <, >, =, ~*, LIKE, ILIKE
AUTHORIZED_FIELDS A list of authorized fields. Used to check queries from browser. Default list is <& SELF:KEY &>, <& SELF:FIELDS &>, <& SELF:FIND_FIELDS &>

FATHER, CHILD Methods

The web page with a father and one or more children can be configured with a collection of methods:

Method Name Description Default Contents Example
CHILD_SELECTED Is intended to be used with multiple child tables;
It indicates which child tab is activated when the page is loaded.
It is empty by default which indicates the first tab will be opened. <%method CHILD_SELECTED>
commissions</%method>
SCHEMA_CHILD_SELECTED Overloads the default method. <&SELF:SCHEMA&>
/
<&SELF:CHILD_SELECTED&>
<%method SCHEMA_CHILD_SELECTED>
demo/commissions</%method>
CHILDREN A comma separated list of children. Empty by default. See the CONFIGURING FATHER .MQL example.
CHILDREN_FIELDS A comma separated list of key fields. Empty by default. See the CONFIGURING FATHER .MQL example.
SCHEMA_CHILDREN A comma separated list of children each prefixed with SELF:SCHEMA The list SELF:CHILDREN with each child prefixed by the SELF:SCHEMA. <%method SCHEMA_CHILDREN>
demo/commissions,demo/employees</%method>
KEY Indicates a primary key of a table. <&SELF:FROM&>
.
<&SELF:KEY_NAME&>
<%method KEY>
orders.id</%method>
KEY_NAME A primary key field without a table name. By default it's derived from the database. <%method KEY_NAME>
id</%method>
SERIAL_SEQ A serial sequence name. <%method SERIAL_SEQ><&SELF:SCHEMA_FROM&>_
<&SELF:KEY_NAME&>_seq
</%method>
<%method SERIAL_SEQ>
<&SELF:SCHEMA_FROM&>_seq</%method>
SELECT_CHILDREN_ID A select statement which is used for listing children keys.
Parameters: $FIELDS, $WHERE, $ORDER
   
CHILDREN_CONTAINER Is used in the frame.html The default value is 'Stack' when there is one child or 'Tab' when there's many children (Tab & Stack are Dojo tooolkit containers)  
CHILD_TEMPLATE Is used in the frame.html; If the method exist in child .mql file it changes its type of form. Does not exist by default. <%method CHILD_TEMPLATE>
FORM</%method>
,
<%method CHILD_TEMPLATE>
TABLE</%method>
,
<%method CHILD_TEMPLATE>
DIVS</%method>
,
<%method CHILD_TEMPLATE>
LINEAR</%method>
or
<%method CHILD_TEMPLATE>
TEMPLATE</%method>
ORDER Determines how to order a table, which columns to order by.
It is important that the sorting must be unique, otherwise the cache mechanism will report errors in the sorting of keys in the cache.
Empty by default.
The recordset is ordered with ascendig primary key.
<%method ORDER>
UPPER(surname), UPPER(name)</%method>
GUI_ORDER GUI user sorting.
List of fields (separated by ",") that the user can sort from the browser. For each field, in addition to the name, the sorting type applied as default (in the list order) and possibly the SQL field code.
- ASC or blank = ascending sort
- DESC = descending sort
- SEL = orderable field in the GUI
In the forms the user can reverse or cancel the sorting of the fields declared here with a click on the field header.
Each variation moves the field to the bottom of the sorting.
A double click on the fields header resets the user-modifiable sorting and the sorting will set by ORDER.
Empty by default.
The recordset is ordered with ORDER.
<%method ORDER_GUI>name ASC UPPER(name), surname ASC UPPER(surname), year SEL, month SEL, day SEL</%method>
FATHER Provides foreign_key_name:father_table_name[:father_primary_key_name] parameters. Empty by default. See the CONFIGURING CHILD .MQL example.
FATHER_WHERE It returns where statement composed of the foreign_key_name and $FATHER_ID parameter. Extracts a foreign_key_name from the FATHER method. Returns <% $field %> = <%$father_id%> string. The $father_id is str2sql_js_delimited($FATHER_ID).  
FATHER_ID_NAME It obtains the father ID field name (foreign_key_name) to be used in insert and update. Extracts the field name from the FATHER method.  
FATHER_NAME It returns a father_table_name. Extracts a full name of the father table (schema.father_name) from the FATHER method.  
FATHER_KEY_NAME It returns an id of the father table (father_primary_key_name). Extracts a father id from the FATHER method.
It also verifies that the father .mql file exists.
 
FATHER_TABLE_KEY_NAME It returns a table.id of the father table. Extracts a father table and id from the FATHER method.
It also verifies that the father .mql file exists.
 

FIELDS Methods

Some of the FIELDS methods were already encountered in previous chapters; Here's the complete list of the FIELDS methods:

Method Name Description Default Contents Example Usage
FIELDS The list of fields from a table to be queried. <%method FIELDS>
<&SELF:INFO,
WHAT => 'NAME_NOPK'&></%method>
See the CONFIGURING CHILD .MQL example.
FIELDS_NOT_NULL When one or more of fields listed in FIELDS_NOT_NULL is empty the row will not to be displayed. Empty. See the NULLS AND AGGREGATE EXPRESSIONS example.
FIELDS_DESCR Labels for the fields. <%method FIELDS_DESCR>
<&SELF:FIELDS&></%method>
<%method FIELDS_DESCR>
Price, Commission ID, Employee ID</%method>
FIELDS_RO Marks fields as Read-Only in the GUI and in the database. Empty. <%method FIELDS_RO>*</%method>
<%method FIELDS_RO>
owner, modification_time, transmission_time</%method>
FIELDS_RO_UPDATE Marks fields as Read-Only in the GUI but they are still writable in the database. The method is useful for processing a values that can not be modified directly by an user. <%method FIELDS_RO_UPDATE>
<&SELF:FIELDS_RO&></%method>

By default the same list as FIELDS_RO method.
<%method FIELDS_RO_UPDATE>
bread</%method>
FIELDS_NO_WRITE An user can supply values in the GUI but can not save them directly to the database. The method is useful for giving an user possibility to supply values which are then processed by the back-end. In practice it may be the value of a SQL view which is processed by the server and does not necessarily correspond to a value to be saved in the database. <%method FIELDS_NO_WRITE>
<&SELF:FIELDS_RO&></%method>

By default the same list as FIELDS_RO method.
<%method FIELDS_NO_WRITE>
flower, salt, yeast, water</%method>
FIELDS_NEW Defines a default new values when user clicks on the Nuovi button.
New default values are separated by comma in the order of method FIELDS.
Empty. <%method FIELDS_NEW>,,,</%method>
defines three new empty fields.
FIELDS_DUP Configures the Duplica button. When pressed the button adds a new record populated with the duplicate values from previous record. The button duplicates the current record (FORM) or the selected record if type is TABLE or DIVS. A comma separated list defines which fields to duplicate. The duplicated field must be marked with a letters d or D. A field marked with upper case letter D is always copied. A field marked with lower case letter d is copied only if not empty. The fields that are not duplicated will be empty or set to default values defined in the FIELDS_NEW method. When the method is empty the Duplica button is not shown. <%method FIELDS_DUP>
d,d,d,,d,,,,d</%method>
FIELDS_HIDDEN A list of hidden fields; See also the HIDDEN parameter of the INFO method. Empty. <%method FIELDS_HIDDEN>
table_name, id_record</%method>

_FIELD Methods

As shown in the examples from previous chapters each field can also be uniquely configured. Here's the list of the FIELD methods:

Method Name Attribute/Parameter Name Description Example Usage
_ALIAS   A field name alias. <%method id_referente_ALIAS>id_socio</%method>
_CHECK   The method that verifies the specified field.
It can be <field_name>_CHECK or
<alias>_CHECK
 
_FIELD   A _FIELD method determines how the field should be displayed. Examples of _FIELD method usage:
Adding Field Method,
Adding Select Field,
Adding HtmlSelect Field,
Adding DivSelect Field,
Adding Child Frame
There are also a couple of examples of _FIELD methods in the global_autohandler file.
  select_name_prefix    
  select_from The select_from is used for setting additional parameters to a select widget to optimize data transfer from server to the browser.
_OUT_FILTER   If the method is defined, applies the filter to the output of the specified field. Returns an array with two fields (value, parameter).  
  $field A field name.  
  $key A primary key value.  
  $value A field value.  
  $names An array of the field names.  
  $fetch_row A hash of the field values.  
  $comp A component (.mql), if not defined using the basic component.  
  $noparam If set to 1, it does not retrieve the parameters (used to optimize in cases where they are not used)  
_NAME_PREFIX      
_FROM      

FIND Methods

Method Name Parameter Name Description Default Value
FIND   The method displays a find-bar for filtering the records. The method can position the find-bar on the left or on the right side of the web page. It uses the GENERIC_FIND method and the FIND_FIELDS, FIND_FIELDS_DESCR settings to display the find-bar.  
FIND_FIELD_WIDTH      
FIND_MENU   The method displays a find-bar for filtering the records. The method positions the find-bar on the top or on the bottom of the web page. It uses the GENERIC_FIND method and the FIND_MENU_PRE, FIND_FIELDS, FIND_FIELDS_DESCR, FIND_MENU_POST settings to display the find-bar.  
  $find_fields A list of fields an user is able to filter. Default value is FIND_FIELDS.
  $Recordset A DataBinding object.  
  $Display A DisplayBinding object.  
  $DescrOnRight Value of the MenuDescrOnRight parameter from the frame.html. Undefined.
GENERIC_FIND   The method displays one input field with find options. The FIND or FIND_MENU use it to construct the find-bar. The find field width can be configured with the FIND_FIELD_WIDTH method. It's possible to customize the GENERIC_FIND behavior for individual find-fields using the <field_name>_FIND_WIDGET methods.  
FIND_MENU_PRE   It is called from FIND_MENU method just before the FIND_MENU form. Example usage: <%method FIND_MENU_PRE><br><br><br></%method>  
FIND_MENU_POST   It is called from FIND_MENU method just after the FIND_MENU form.  
_FIND_FIELD   Defines an input widget to be used for specific find-field. Is used by the Find_Component() subroutine. Does not exist by default.
_FIND_ALIAS   Defines an input widget to be used for specific find-field. Is used by the Find_Component() subroutine. Does not exist by default.

Query Methods and Subroutines

There's a general convention to use the PRE, POST and POST_NO methods for handling fields in the tables and INSERT, UPDATE and DELETE methods for defining complete queries.

SELECT

Method Name Arguments Description Default Contents Example Usage
SELECT_FIELDS   A list of fields to be inserted into table's select query. <%method SELECT_FIELDS>
<&SELF:FIELDS&>
</%method>

By default identical to the FIELDS method.
<%method SELECT_FIELDS>
nome, cognome, codice_fiscale, descrizione, indirizzo, provincia, citta, tel1, tel2, cell_sms, email, login, '' as password, no_psw_expiration
</%method>
JOIN_TABLES   Is used for defining additional join clauses. <%method JOIN_TABLES>
<&SELF:SCHEMA_FROM&>
</%method>
See data/public/messages_users_detail.mql and
data/public/user_messages.mql
WHERE   A contents of WHERE statement. Empty. <%method WHERE>
zone.id_coordinatore = soci.id
</%method>
EVAL_WHERE   Evaluates the query provided by the browser. It is called from SelectWhere() to check the SQL query for unauthorized access (sql injection). Method does not exist by default.  
  $where The parameter contains the query from the browser.    
SELECT_WHERE   Is passed to the EvalSqlWhere(). <%method SELECT_WHERE>
<&SELF:WHERE&>
</%method>
 
PRE_SELECT   The method is called just before SELECT query. Method does not exist by default. See data/public/logs_report.mql
  $PARAMS The argument contains optional parameters for the prepared query.    
  $ID   Parameter undefined by default.
When defined it is compared to <&SELF:KEY&> = <% encodeSql($ID)
 
  $WHERE WHERE statement.    
DIV_SELECT        

INSERT, UPDATE, DELETE

Method Name Arguments 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&>');
  $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.  
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) %>;
  $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.  
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) %>;
  $KEY A primary key.  

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.

Auxiliary Methods

Method Name Arguments Description Default Contents
DELETE_IF_FIELD_EMPTY   Contains a list of field names. Defines which field causes execution of PRE_DELETE and DELETE on the specified row prior to UPDATE, when the field is empty. By default the method does not exist.
ENTITY_CHILDREN      
ENTITY_FIELDS      
ENTITY_RELATIONS      
DB_LOG   Add variations to logs table  
  $type update type (insert, update, delete)  
  $id record id (PK)  
  $fields hash of modified fields  
  $old_fields hash of original fields undef
  $table_name table name (with schema) undef

Query Subroutines

Name Arguments Description
Array2UpdateSql()   The subroutine is used for updating or inserting records sent by GUI in an array format. The array is passed from gotoRecords method from the lib/databinding.js in the update parameter and it contains only record-sets of changed or inserted fields. The record-set exchanged between a server and a browser are in a array format with the Primary Key in the first column and fields in the same positions as defined with the FIELDS method from the .mql file.
Call_OutFieldFilter()   See the _OUT_FILTER method.
Call_InFieldFilter   If the _IN_FILTER method is defined, applies the filter to the specified field.
EvalSqlWhere()    
ExecQuery()    
PrepareQuery()    
SelectWhere()    
SqlSelect()    
SqlWhere()    
str2sql_js_delimited()   It returns a string adapted to be inserted into a SQL query, or to be inserted in a JavaScript code.

XLS Methods

Method Name Description Default Contents
xls Is the method that is called when user presses the XLS button.
Its default behavior can be changed with SELECT_XLS, SELECT_XLS_FIELDS and TYPE_FIELDS_XLS methods.
The method exports currently displayed table into the .xls file.
The Xls permissions relate specifically to this function.
SELECT_XLS A select query that configures SqlSelect() subroutine from the xls method. <%method SELECT_XLS>
<&SELF:SELECT, %ARGS&>
</%method>
SELECT_XLS_FIELDS A list of select fields for the query from the xls method. The list configures SqlSelect() subroutine. <%method SELECT_XLS_FIELDS>
<&SELF:SELECT_FIELDS&>
</%method>
TYPE_FIELDS_XLS A list of field types in the XLS table. If the method is not defined the xls method tries to obtain field types from the database.
(In old release <= 1.9.1, inclusive in the initial position with the format (number) of the primary key)
Not defined.

Forms Methods

Forms

Some of these methods are related to methods in frame.html.

Method Name Parameter Name Description Default Value
FORM_TYPE   TABLE, DIVS, FORM, TEMPLATE or LINEAR, see also frame.html. FORM
FORM_HEADER   The method shows the header bar which displays the methods in this order:
The CONTROLS method, HEADER_INCLUDE method and the DESCRIPTION method.
Empty method.
HEADER_INCLUDE   Displays additional fields in the table header. Used by the FORM_HEADER method.  
TABLE   The generic method which displays records in a table.  
TABLE_HEADER   The generic method which displays the table header.  
TABLE_ROWS   Number of rows in TABLE or in DIVS form.  
ROW_TABLE   The generic row method for browsing the table with TABLE method. Used only by TABLE method.  
DIVS   The generic method which displays records in rows but without table header.  
ALL_ROW_DIVS      
ROW_DIVS   The generic row method for browsing the DIVS type of table. Used by DIVS and ALL_ROW_DIVS methods.  
SEP_DIV   The <div> separator. Used only by DIVS method. <hr>
FORM   The form method displays one record at a time.  
LINEAR   The generic form method with a linear format for browsing the database table.
In this format the fields are sorted in the order in which they were listed.
To interrupt a line insert the character / at the bottom of the field description.
 
TEMPLATE   The generic form for browsing the database table.
The fields are inserted into the template with the provided FORM_TEMPLATE method
(or with parameter $Template).
For example:
<%method FORM_TEMPLATE><p><DESCR:description>:<FIELD:description></p></%method>
See also FATHER_TEMPLATE, CHILDREN_TEMPLATE and CHILD_TEMPLATE in frame.html.
 
FORM_TEMPLATE   The generic form for browsing the database table.
Display or edit single record at a time.
For example:
<%method FORM_TEMPLATE><p>:</p></%method>
 
DIVS_TEMPLATE   The generic method for browsing the database table.
Display or edit multiple records at a time.
For example:
<%method DIVS_TEMPLATE>Rec: <RECORD><CHECKBOX><DESCR:par_id>:<FIELD:par_id><DESCR:cod>:<FIELD:cod><DESCR:unit>:<FIELD:unit><DESCR:prezzo>:<FIELD:prezzo><DESCR:rifer>:<FIELD:rifer>
 
ROW_DIVS_TEMPLATE   The generic row method for browsing the table with DIVS_TEMPLATE.
Used only by DIVS_TEMPLATE.
 
GENERIC_FIELD      
GENERIC_D_FIELD      
BOOL_FIND_FIELD      
STANDARD_FIELD      
FIELD_ROW_DIVS   DEPRECATED: Its beavior to permit to view in GUI a variable number of rows modified by GUI with preloaded templates. The beavior is activated with FIELD_ROW_DIVS method (name of field record that determining the type of line in the case of type DIVS template variables).  

Method Name Parameter Name Description Default Value
CONTROLS   The method shows the control bar with refresh, navigation, modify, delete, save and the rest of the control buttons. The enabling of the buttons depends on the configuration but can also be individually passed to the frame.html.  
  $disp_navbar Display control bar. 1
  $disp_cancel Display Annulla button. 1
  $disp_refresh Display Aggiorna buttton. 1
  $disp_change Display Modifica button. 1
  $disp_insert Display Nuovo button. 1
  $disp_dup Display Duplica button. 0
  $disp_save Display Salva button. 1
  $disp_delete Display Cancella button. 1
  $disp_print Display Stampa button. 1
  $disp_xls Display XLS button. 1
  $disp_log Display LOG button. 1
BUTTON_Ctrl_filter   The Filtra button in the find bar. Calls loadRecords('rewind')
BUTTON_Ctrl_printsel   The St.sel button in the find bar. Calls printSelected('recordset')
BUTTON_Ctrl_xlssel   The XLS button in the find bar. Calls printSelected('xls_recordset')

Report Methods, Subroutines and Component

Report Methods

The report methods are called when a browser makes a pdf query request (see Testing Queries).
The query request is initiated with printSelected() function, from DisplayBinding object.
The printSelected() uses the printUrl() function, from DataBinding object, to construct query request url with attached parameters.

Method Name Parameter Name Description Default Value
pdf   The method wraps around the PDF method. The method gets $GROUP_ID and $report_ids by calling SqlSelect2report_id() and passes them to the PDF method. Afterwards, when the PDF returns, it removes all $GROUP_ID records from public.report_id table with delete print group query.  
PDF   Prepares the parameters for the report.pdf component.  
  $GROUP_ID Is simply passed forward. Not defined.
  $report_ids It's checked if the REPORT_ID argument exists which overrides the $report_ids. The REPORT_ID can be defined defined in the ODT Reports as one of the cmd_parameters that are used for testing ODT reports. Then the $report_ids is passed forward to the report.pdf component. Not defined.
  $LANDSCAPE If it finds $LANDSCAPE parameter in a list of parameters it is discarded. Not defined.
  $report The parameter represents name of the report file used by the Reportman or ODT Reportman to generate the report. Not defined.
  $report_method The report method is determined by the ReportMethod() subroutine. Valid values are: rep, odt or pdf. None.
  $report_file The $report_file is used by the Reportman. The value is determined by the FindReportmanFile() subroutine.  
PRINT_FORM   Schema/form_name to be used for the report with attached orientation. See the button example. <%method PRINT_FORM>\
% my $schema = $m->scomp('SELF:SCHEMA');
% if($schema eq 'public'){
<& SELF:FROM &>\
% }else{
<& SELF:SCHEMA &>/<& SELF:FROM &>\
% }
, PORTRAIT, \
</%method>
PRINT_RECORDS   The method inserts the primary key of the public.recorset table and the group_id in the public.report_id table.  
  $WHERE   Empty string.
  $GROUP_ID   Not defined.

Report Subroutines

DBMS Library subroutines related to reporting.

Subroutine Name Parameter Name Valid Input Value Description
Array2report_idSql()     Inserts each key from the $arr list into the public.report_id table. Returns $group_id and $report_ids.
  $group_id   Group ID.
  $arr   A list of parameters.
FindReportmanFile()     Uses request_to_comp_path() subroutine with different combinations of the parameter $report and the Apache config variable ReportmanADOserver to find the right Reportman configuration file.
  $report   The report name.
  ReportmanADOserver   If this Apache configuration variable exists the subroutine searches for and validates the Wine report configuration files. Otherwise the subroutine searches for and validates the Kylix report configuration files.
ReportMethod()     Analyzes the report name to determine which reporting method is used (Reportman or ODT Report. The subroutine first tries to determine the reporting method from the $report suffix. If there is no suffix present it uses the value of the Apache config variable DefaultReportEngine. If it finds unknown report suffix or if the DefaultReportEngine is not defined it raises an error.
  $report   The report name. Optional suffix determines the reporting method. See the button example to understand how the $report name is constructed.
    my_report_name.rep The report will be created with the Report Manager and printed in .pdf format.
    my_report_name.odt The report will be created with the ODT Report and printed in .odt format.
    my_report_name.pdf The report will be created with the ODT Report and printed in .pdf format.
NewGroupId()     Uses Apache config variable PrintNextValQuery to obtain new group ID value.
By default, if the config variable is missing, it uses select nextval('public.report_id_id_seq') query.
SqlSelect2report_id()     It uses the NewGroupId() to get a new $group_id value. Initializes the report_id table with the IDs of the records to be printed. Returns $group_id and $report_ids to be passed as parameters to the PDF method. The returned parameter $group_id contains a $GROUP_ID value. The returned parameter $report_ids contains a reference to an array of a $REPORT_ID values.
  $Params->{'reportlist'}   If the reportlist parameter is defined the function returns Array2report_idSql()
  $Params->{'type'}   Otherwise, if the reportlist parameter is not defined, the $Params->{'type'} is set to records
  $Params->{'where'} and $Params->{'numrec'}   Both parameters are used for making SqlSelect2report_id numrec query.
The result of the query is saved to $SQL{MAX_ROWS}
  $Params->{'where'}   Is also used for making SqlSelect2report_id print query.

Report Component

report.pdf Component

Universal Methods and Subroutines

Method or
Subroutine Name
Parameter Name Valid Input Value or
Attribute Value
Description Default Value
Find_Component()     Returns the name of the component to be used in the search field.
It first seeks for _FIND_FIELD, _FIND_ALIAS, _ALIAS, _FIELD methods.
If component is not found it returns BOOL_FIND_FIELD or STANDARD_FIELD.
INFO     Retrieves information from a .mql file and from a database table.
It is cached in global hash $Global{"ATTRS_<SCHEMA>_<TABLE>"}
 
    NAME The INFO method will retrieve all fields parameters or parameters of one field with parameter NAME. See also FIELDS method.  
    TYPE Data type of the field (integer, float, ...)
The parameter limits the response to the requested type of query.
 
    SIZE The field size in digits.  
    DECIMAL Decimal size of the field.  
    NOTNULL The field is not null-able; See also FIELDS_NOT_NULL method.  
    PRIMARY_KEY The field is a primary key.  
    DESCR Use description from the FIELDS_DESCR method.  
    FIND_DESCR Use description from FIND_FIELDS_DESCR method.  
    HIDDEN The field is not visible. Non-visible fields are defined with FIELDS_HIDDEN method.  
List2Array()     Converts an input string into an array using input separator.  
  $list   Input string.  
  $sep   Input separator. The default separator is ,
         
Topic revision: r38 - 22 Apr 2018, GuidoBrugnara
This site is powered by FoswikiCopyright (©) Leader.IT - Italy P.I. IT01434390223 Privacy policy & use of cookies