varlena ere: Variables




How It Works

Design Structure


Design a Report


Built-in Arguments


Using CSV files



Reports Home

Variable Types

There are four kinds of variables in ere.
  • Column variables
  • Command line arguments
  • Declared variables
  • Built-in variables

Command line arguments can be used anywhere. Variables can be used after declaration. Column values must be contained within an area associated with the corresponding datastream. They must be elements of the targetlist for that datastream. The containment area need not be the immediate enclosing area but may be in a parent area. Built-in arguments are documented in the Built-in Arguments and in Using CSV files.

Column values

Column variables are defined to be the target list of each datastream. The value of the variable is the value of the column of the current row. Column values are usually used in repeated areas, for example:
         <area name=detail datastream=teams break=teamname>

Column variables must be used in areas defining the datastream from which they originate.

Command Line Arguments and Variables

Command line arguments are simply name=value pairs passed on the command line invoking ere.
	% ere tablelist tablename=users

Command line arguments and declared variables are embedded by name. The name is enclosed in colons. They can be used anywhere in the report, including the SQL.

	... AND datefield = :datearg:

Using Declared variables

Simple declared variables are usually declared in the report header section like this:
	<var name=title value="Hattie's Kitchen" /var>
These are usually constants, useful when you are using a single report template as the basis of a variety of reports.

Declared variables are much more useful when the value is based on a command line variable. Declared variables have an extra twist in that they can be set or unset based on the values of command line arguments. If the value of any command line argument used in a declared variable evaluates to an empty string, then the declared variable value will also be set to an empty string. This is used to create optional clauses in the SQL statement based on command line arguments.

For example, report myreport.xml declares two variables that are used as additional qualifiers in the SQL statement. When the report is run, only one of the command line variables, lastname, is passed in.

   % cat myreport.xml
      <Var name=quallname value="AND lastname = ':lastname:' "  /Var>
      <Var name=qualfname value="AND firstname = ':firstname:' "  /Var>
      select ....
         where ....
            :quallname: :qualfname:
         order by ....

   % ere myreport lastname=Howard

When the variable quallname is evaluated, it will have the value "AND lastname = 'Howard'". When the variable qualfname is evaluated it will be an empty string. The variables can be used in the SQL statement so that it can qualify on "lastname" and not "firstname" based on the arguments passed in at runtime.

Copyright 2003 through 2009 A. Elein Mustain, Varlena, LLC