Doco Home Tools Home
dev_conf

QUERY Section in Configuration files

The QUERY section is used by Squirt to generate stub code for querying the database. The QUERY section is detailed within this document.

QUERY.queryname.DO = <table_name>
MANDATORY
<table_name> is the Java-ised table name, i.e. it's the name of table used in Java as created in DODS. The results of the query are zero or more DOs of this table.

QUERY.queryname.TYPE = <query_type>
OPTIONAL
<query_type> is one of the following: "EASY", "CUSTOM" or "OBJECTID". If this option is not specified, then the TYPE is assumed to be "EASY". This option influences the type of code to be generated.

QUERY.queryname.PARAMETERS[] = <param_list>
OPTIONAL
<param_list> is a comma separated list of variables passed to query. The method name for the query is the queryname. If this option is not set, the query method has no parameters.

QUERY.queryname.PARAMTYPES[] = <param_types>
OPTIONAL
<param_types> is a comma separated list of the java types for each parameter passed to the query. This list must be exactly the same length as the PARAMETERS list as each parameter must have a type. If this option is not set, the query method must have no parameters.

QUERY.queryname.NULL_ALLOWED[] = <null_allowed>
OPTIONAL
<null_allowed> is a comma separated list that has exactly the same number of entries as the <param_list> above. Each entry is either INCLUDE or EXCLUDE. If the entry is INCLUDE, then the parameter is included in the query even if the passed value is null. The value of EXCLUDE means that the parameter is not included in the query if the passed value is null or empty. If this option is not set, all parameters are assumed to have the EXCLUDE option.

QUERY.queryname.UNIQUE = true | false
OPTIONAL
If this option is set, then the query must return zero or one instance only. If this option is not set, then false is assumed.

QUERY.queryname.ORDERBY[] = <orderby_list>
OPTIONAL
This option only applies for "EASY" query types. The <orderby_list> is the list of fields to order by. This list is currently limited to fields of the result table.

QUERY.queryname.SQL subsection:
OPTIONAL
This subsection details the SQL code for this query. It's only relevant if the TYPE is "CUSTOM".

QUERY.queryname.SQL.SELECT = <select_code>
QUERY.queryname.SQL.FROM = <from_code>
QUERY.queryname.SQL.WHERE.clause#.CODE = <where_clause_code>
QUERY.queryname.SQL.WHERE.clause#.OPERATOR = <where_clause_operator>

  • <select_code> is the SELECT portion of the SQL code. If this is not set, then the default "*" is used. This option is ignored in version 1 of squirt - the default is assumed.
  • <from_code> is the FROM portion of the SQL code. If this is not set, then the default is the DO.TABLE.tablename.SQL_NAME value from dev.conf, where tablename is the value of QUERY.queryname.DO. This option is ignored in version 1 of squirt.
  • The 'clause#' subsections are each portion of the where clause, if any. Numbering starts from 1.
  • <where_clause_code> is a portion of the WHERE clause. Within this code, the use of <parameter_name> allows the substitution of a parameter to the method into the query.
  • <where_clause_operator> is the 'joining' code between this clause's code and the previous clause's code. If the OPERATOR option is set for a particular clause #, then the CODE option must also be set.
  • Example: If the SQL query is "SELECT * FROM t_person WHERE Surname LIKE '<Surname>' AND Age > <Age>", then the configuration for the SQL subsection would be:

    The code generated will expect 2 String parameters: Surname and Age. These parameters are substituted into the CODE portions. Note that clause1 doesn't need an OPERATOR and in most cases probably will not have one.