12. Report-Writer Statements : Report Setup Statements : .Declare Statement—Declare Variables : Examples
 
Share this page                  
Examples
1. Declare variables using with prompt, with null, and not null.
.declare
   counter = integer,
   salary = money with prompt
      'Please enter the salary:',
   spouse = c30 with null,
   dept = i4 not null with prompt
      'What department?'
2. Declare variables using with value in .include files "BR_fmts.rw" and "AM_fmts.rw," and then include the appropriate definition for that version of your report.
.declare date_fmt = c30 with value 'd\'03/20/01\''
or
.declare date_fmt = c30 with value 'd\'02/03/01\''
The main body of the report can be written independently of the exact value of the date format; for example:
.print current_date ($date_fmt)
3. Declare a variable with a value that is an schema‑qualified table name.
.declare var1 = varchar(65) with value 'mike.table_abcd'
The schema and table name can be delimited identifiers, if you have specified the .delimid statement. The variables have been declared with the maximum size to accommodate a compound identifier in which each part is a delimited identifier.
.delimid
.declare var2 = varchar(133)
   with value 'jane."table efg"'
.declare var3 = varchar(133)
   with value '"c bradley".table_hijk'
.declare var4 = varchar(133)
   with value '"r panzer"."table xyz"'