+ All Categories

SQR

Date post: 16-Oct-2015
Category:
Upload: joannac08
View: 36 times
Download: 0 times
Share this document with a friend
Popular Tags:

of 477

Transcript
  • SQR Language Reference

    Version 4.3.2

    1080 Marsh Road,Menlo Park, California 94025

  • SQR Language Reference, Version 4.3.2

    Part number 06-M-4301-R01

    Copyright SQRIBE Technologies, 1998.

    All rights reserved. Printed in the USA.

    This publication pertains to SQR 4.3.2 and to any subsequent release untilotherwise indicated in new editions or technical notes. Information in thisdocument is subject to change without notice. The software described hereinis furnished under a license agreement, and it may be used or copied only inaccordance with the terms of the agreement.

    LIMITED WARRANTY

    THE SQR PROGRAM AND PRODUCT DOCUMENTATION ARE SOLD "AS IS,"WITHOUT WARRANT AS TO THEIR PERFORMANCE, MERCHANTABILITY, ORFITNESS FOR ANY PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE RESULTSAND PERFORMANCE OF THIS PROGRAM IS ASSUMED BY YOU.

    HOWEVER, TO THE ORIGINAL PURCHASER ONLY, THE PUBLISHER WARRANTSTHE MAGNETIC MEDIUM ON WHICH THE PROGRAM IS RECORDED TO BE FREEFROM DEFECTS IN MATERIALS AND FAULTY WORKMANSHIP UNDER NORMALUSE FOR A PERIOD OF NINETY DAYS FROM THE DATE OF PURCHASE. IF DURINGTHE NINETY-DAY PERIOD THE MEDIUM SHOULD BECOME DEFECTIVE, IT MAY BERETURNED TO THE PUBLISHER FOR A REPLACEMENT WITHOUT CHARGE,PROVIDED YOU HAVE PREVIOUSLY EXECUTED A SOFTWARE LICENSEAGREEMENT.

    SQRIBE, SQR, SQR Execute, SQR Print, SQR Viewer, VisualSQRIBE,InSQRIBE, PowerSQRIBE, WebSQRIBE, ReportMart, RM/API, RM/InSQRIBE,RM/Publisher, RM/Script, and Instant HTML are trademarks or registeredtrademarks of SQRIBE Technologies.

    All other company and product names used herein may be the trademarks orregistered trademarks of their respective companies.

  • Contents iii

    ContentsPREFACE ......................................................................................................IX

    Audience ........................................................................................................................... ixHow to Use This Book...................................................................................................... ixRelated Documents............................................................................................................ xIf You Need Help............................................................................................................... x

    1 INTRODUCTION ...................................................................................1About SQR ......................................................................................................................... 1The SQR Program Structure ............................................................................................. 3

    Syntax Conventions ....................................................................................................... 4Rules for Entering Commands ......................................................................................... 4

    The SQR Command Line............................................................................................... 5SQR Data Elements ...................................................................................................... 13

    Viewing Sample Reports ................................................................................................. 162 SQR COMMAND REFERENCE ......................................................... 17

    ADD .............................................................................................................................. 19ALTER-LOCALE ......................................................................................................... 21ALTER-PRINTER......................................................................................................... 30ARRAY-ADD ............................................................................................................... 32ARRAY-DIVIDE........................................................................................................... 32ARRAY-MULTIPLY .................................................................................................... 32ARRAY-SUBTRACT.................................................................................................... 32ASK ............................................................................................................................... 35BEGIN-DOCUMENT................................................................................................... 37BEGIN-FOOTING........................................................................................................ 39BEGIN-HEADING....................................................................................................... 41BEGIN-PROCEDURE .................................................................................................. 43BEGIN-PROGRAM...................................................................................................... 46BEGIN-SELECT............................................................................................................ 47BEGIN-SETUP.............................................................................................................. 50BEGIN-SQL .................................................................................................................. 52BREAK .......................................................................................................................... 56CALL............................................................................................................................. 57CALL SYSTEM............................................................................................................. 57CLEAR-ARRAY ........................................................................................................... 64CLOSE........................................................................................................................... 65COLUMNS ................................................................................................................... 66COMMIT....................................................................................................................... 67CONCAT ...................................................................................................................... 69CONNECT.................................................................................................................... 71

  • SQR Language Reference SQR 4.3

    iv Contents

    CREATE-ARRAY ......................................................................................................... 73#DEBUG........................................................................................................................ 76DECLARE-CHART ...................................................................................................... 78DECLARE-IMAGE....................................................................................................... 86DECLARE-LAYOUT.................................................................................................... 88DECLARE-PRINTER ................................................................................................... 95DECLARE-PROCEDURE .......................................................................................... 103DECLARE-REPORT................................................................................................... 105DECLARE-TOC.......................................................................................................... 107DECLARE-VARIABLE .............................................................................................. 109#DEFINE ..................................................................................................................... 113DISPLAY..................................................................................................................... 115DIVIDE........................................................................................................................ 119DO ............................................................................................................................... 121#ELSE .......................................................................................................................... 123ELSE ............................................................................................................................ 124ENCODE..................................................................................................................... 125END-DECLARE ......................................................................................................... 126END-DOCUMENT .................................................................................................... 126END-EVALUATE ...................................................................................................... 126END-FOOTING.......................................................................................................... 126END-HEADING......................................................................................................... 126#END-IF ...................................................................................................................... 128#ENDIF........................................................................................................................ 128END-IF ........................................................................................................................ 129END-PROCEDURE.................................................................................................... 130END-PROGRAM........................................................................................................ 130END-SELECT ............................................................................................................. 130END-SETUP................................................................................................................ 130END-SQL .................................................................................................................... 130END-WHILE............................................................................................................... 130EVALUATE ................................................................................................................ 132EXECUTE (Ingres)................................................................................................... 135EXECUTE (SYBASE and Microsoft SQL Server).................................................. 137EXIT-SELECT ............................................................................................................. 140EXTRACT.................................................................................................................... 141FIND............................................................................................................................ 143GET.............................................................................................................................. 145GOTO .......................................................................................................................... 147GRAPHIC BOX........................................................................................................... 148GRAPHIC HORZ-LINE............................................................................................. 148GRAPHIC VERT-LINE .............................................................................................. 148#IF ................................................................................................................................ 151

  • SQR 4.3 SQR Language Reference

    Contents v

    IF.................................................................................................................................. 154#IFDEF ........................................................................................................................ 156#IFNDEF ..................................................................................................................... 157#INCLUDE ................................................................................................................. 158INPUT ......................................................................................................................... 160LAST-PAGE................................................................................................................ 164LET .............................................................................................................................. 165LOAD-LOOKUP ........................................................................................................ 187LOOKUP..................................................................................................................... 191LOWERCASE ............................................................................................................. 193MBTOSBS (Double-byte Version of SQR Only)....................................................... 194MOVE ......................................................................................................................... 195MULTIPLY ................................................................................................................. 200NEW-PAGE ................................................................................................................ 202NEW-REPORT ........................................................................................................... 203NEXT-COLUMN........................................................................................................ 205NEXT-LISTING .......................................................................................................... 207OPEN .......................................................................................................................... 209PAGE-NUMBER ........................................................................................................ 211POSITION................................................................................................................... 212PRINT.......................................................................................................................... 213PRINT-BAR-CODE .................................................................................................... 235PRINT-CHART .......................................................................................................... 239PRINT-DIRECT .......................................................................................................... 248PRINT-IMAGE ........................................................................................................... 250PUT.............................................................................................................................. 252READ .......................................................................................................................... 254ROLLBACK ................................................................................................................ 257SBTOMBS (Double-byte Version of SQR Only)....................................................... 258SHOW ......................................................................................................................... 259STOP............................................................................................................................ 264STRING....................................................................................................................... 265SUBTRACT................................................................................................................. 267TOC-ENTRY............................................................................................................... 269UNSTRING................................................................................................................. 270UPPERCASE............................................................................................................... 272USE.............................................................................................................................. 273USE-COLUMN........................................................................................................... 274USE-PRINTER-TYPE ................................................................................................. 275USE-PROCEDURE..................................................................................................... 276USE-REPORT ............................................................................................................. 278WHILE ........................................................................................................................ 279WRITE......................................................................................................................... 281

  • SQR Language Reference SQR 4.3

    vi Contents

    3 HTML PROCEDURES ....................................................................... 283HTML General Purpose Procedures ............................................................................ 284HTML Heading Procedures.......................................................................................... 287HTML Highlighting Procedures................................................................................... 289HTML Hypertext Link Procedures .............................................................................. 293HTML List Procedures .................................................................................................. 294HTML Table Procedures ............................................................................................... 297

    4 SQR EXECUTE .................................................................................... 3015 SQR PRINT.......................................................................................... 3076 OLD SQR COMMANDS................................................................... 311

    BEGIN-REPORT ......................................................................................................... 312DATE-TIME................................................................................................................ 313DECLARE PRINTER.................................................................................................. 315DECLARE PROCEDURE .......................................................................................... 321DOLLAR-SYMBOL .................................................................................................... 323GRAPHIC FONT........................................................................................................ 326MONEY-SYMBOL...................................................................................................... 328NO-FORMFEED......................................................................................................... 330PAGE-SIZE ................................................................................................................. 331PRINT CODE.......................................................................................................... 333PRINTER-DEINIT ...................................................................................................... 334PRINTER-INIT............................................................................................................ 335

    7 SAMPLE REPORTS............................................................................ 3368 SQR.INI................................................................................................ 3419 SQR MESSAGES ............................................................................... 353

    Unnumbered Messages ................................................................................................. 353Numbered Messages ..................................................................................................... 357

    INDEX......................................................................................................... 455

  • Tables vii

    TablesTABLE 1. SYNTAX CONVENTIONS ............................................................................................ 4TABLE 2. SQR COMMAND-LINE ARGUMENTS ...................................................................... 5TABLE 3. SQR COMMAND-LINE FLAGS ................................................................................... 7TABLE 4. SQR RESERVED VARIABLES..................................................................................... 14TABLE 5. SYNTAX ABBREVIATION CONVENTIONS........................................................... 17TABLE 6. 'SYSTEM' LOCALE SETTINGS ................................................................................... 24TABLE 7. OPERATING SYSTEM STATUS VALUES FOR THE CALL COMMAND .......... 58TABLE 8. UCALL SUBROUTINE ARGUMENTS...................................................................... 59TABLE 9. DECLARE-CHART COMMAND ARGUMENTS .................................................... 79TABLE 10. PRINTER.COLOR SETTING EFFECT ON CHART.FILL...................................... 84TABLE 11. UOM VALID SUFFIXES............................................................................................. 89TABLE 12. VALID PAPER NAMES ............................................................................................. 89TABLE 13. DECLARE-LAYOUT COMMAND ARGUMENTS................................................ 90TABLE 14. DECLARE-PRINTER COMMAND ARGUMENTS ............................................... 96TABLE 16. FONTS AVAILABLE FOR HP LASERJET PRINTERS IN SQR ............................ 99TABLE 18. FONTS AVAILABLE FOR POSTSCRIPT PRINTERS .......................................... 100TABLE 19. FONTS AVAILABLE FOR WINDOWS PRINTERS ............................................. 101TABLE 18. SQR COMPILER DIRECTIVES................................................................................ 152TABLE 19. DATATYPES SUPPORTED BY THE INPUT COMMAND ................................ 161TABLE 20. VALUES OF THE STATUS ARGUMENT OF THE INPUT COMMAND........ 162TABLE 21. OPERATORS.............................................................................................................. 167TABLE 22. NUMERIC FUNCTIONS.......................................................................................... 168TABLE 23. FILE-RELATED FUNCTIONS................................................................................. 174TABLE 26. MISCELLANEOUS FUNCTIONS........................................................................... 175TABLE 25. VALID PRINT FORMAT COMMAND COMBINATIONS ................................ 214TABLE 26. TEXT EDIT FORMAT CHARACTERS................................................................... 218TABLE 27. NUMERIC EDIT FORMAT CHARACTERS ......................................................... 219TABLE 28. SAMPLE EDIT MASKS ............................................................................................ 220TABLE 29. DATE EDIT FORMAT CODES................................................................................ 221TABLE 30. DATE EDIT FORMAT CODE-RR........................................................................... 222TABLE 31. SAMPLE DATE EDIT MASKS ................................................................................ 223TABLE 32. DEFAULT DATABASE FORMATS........................................................................ 225TABLE 34. DATE COLUMN FORMATS................................................................................... 225TABLE 35. TIME COLUMN FORMATS.................................................................................... 225TABLE 35. BAR CODE TYPES .................................................................................................... 236TABLE 36. CHART ARRAY FIELD TYPES............................................................................... 243TABLE 37. HTML GENERAL PURPOSE PROCEDURES ...................................................... 284TABLE 38. HTML HEADING PROCEDURES ......................................................................... 287TABLE 39. HTML HIGHLIGHTING PROCEDURES.............................................................. 289TABLE 40. HTML HYPERTEXT LINK PROCEDURES........................................................... 293TABLE 41. HTML LIST PROCEDURES..................................................................................... 294TABLE 42. HTML TABLE PROCEDURES ................................................................................ 297

  • SQR Language Reference SQR 4.3

    viii Tables

    TABLE 43. SQR EXECUTE COMMAND-LINE FLAGS.......................................................... 301TABLE 44. SQR PRINT COMMAND-LINE FLAGS ................................................................ 308TABLE 45. DEFAULT DATE-TIME FORMATS ....................................................................... 314TABLE 46. DECLARE PRINTER COMMAND ARGUMENTS.............................................. 316TABLE 47. CHARACTERS DISALLOWED IN THE DOLLAR-SYMBOL COMMAND.... 324TABLE 48. SQR SAMPLE REPORTS.......................................................................................... 336TABLE 49. ENTRIES FOR DEFAULT-SETTINGS SECTION ................................................. 342TABLE 50. ENTRIES FOR PROCESSING-LIMITS SECTION................................................. 345TABLE 51. ENTRIES FOR LOCALE SECTION ........................................................................ 347TABLE 52. ENTRIES FOR HTML-IMAGES SECTION............................................................ 350TABLE 53. ENTRIES FOR ENHANCED HTML SECTION..................................................... 351

    FiguresFIGURE 1. SAMPLE ARRAY ........................................................................................................ 75FIGURE 2. SAMPLE UPC-A BAR CODE .................................................................................. 237FIGURE 3. SAMPLE ZIP+4 POSTNET BAR CODE................................................................. 238FIGURE 4. SAMPLE PIE CHART ............................................................................................... 247

  • Preface ix

    Preface

    The SQR Language Reference gives the complete syntax for SQR. Information youneed to create, run, test, and debug SQR programs is contained in this guide.

    Audience

    This guide was written for programmers developing reports for relational databases.To use this book effectively, you need a working knowledge of SQL and hands-onexperience with writing computer programs. You also need to be familiar with yourparticular database and operating system.

    How to Use This Book

    This book contains the following chapters:

    Chapter 1 introduces you to SQR.

    Chapter 2, "SQR Command Reference," describes the SQR commands andarguments, and provides examples of how to use the commands.

    Chapter 3, "HTML Procedures," describes how to use an SQR program togenerate HTML output.

    Chapter 4, "SQR Execute," describes how to use SQR Execute to run aprecompiled SQR program.

    Chapter 5, "SQR Print," describes how to use the SQR Print to create report filesfor each supported printer type.

    Chapter 6, "Old SQR Commands," lists commands used prior to version 4.0 andinforms the user which commands to use in their place.

    Chapter 7, "Sample Reports," lists the file names and descriptions of samplereports that are available online.

    Chapter 8, "SQR.INI," describes the contents of the SQR.INI file. Each section ofthis file is listed and fully described.

    Chapter 9, "SQR Messages," lists messages issued by SQR. For each message, anexplanation and a suggested action are given.

  • SQR Language Reference SQR 4.3

    x Preface

    Related Documents

    In addition to this book, the SQR product set includes the following documentation:

    SQR User's Guide provides step-by-step instructions on how to use SQR. Thisguide gives you the framework for creating many different types of SQRprograms.

    VisualSQRIBE User's Guide explains how to quickly create SQR reports onWindows systems using the VisualSQRIBE GUI application.

    Installation Guides contain installation instructions and configuration informationspecific to your platform.

    Release Notes describe enhancements and new features.

    If You Need Help

    If you are unable to resolve an SQR question or problem using product manuals andonline help and you have a valid SQRIBE Technologies support agreement, you maycontact SQRIBE Technical Support from 6:00 AM to 5:30 PM Pacific Time at1.800.437.1663 (within North America) or, +1.562.436.7489 (outside of North America).You may also send an e-mail message to [email protected]. Please be prepared toprovide a valid customer number and company name. You will also need to know theversion of SQR you are using, your operating system and database names andversions. If you wish to execute a SQRIBE support agreement, please call1.888.473.6391.

  • Introduction 1

    1 IntroductionSQR is a comprehensive multi-RDBMS reporting system designed to deliver the fullrange of SQL reporting requirements. With SQR you have a simple and efficient way tocombine the benefits of SQL with the advantages of a procedural programminglanguage.

    SQR Server is comprised of:

    The SQR language, a procedural 4GL report generator for SQL-based relationaldatabases. Write SQR application source programs in any text editor to createsimple or complex reports.

    Sample programs, along with report output, to give you the framework forcreating several different types of reports.

    SQR Viewer, which allows you to view reports on-line.

    SQR Print, a printer for reports generated by SQR or SQR Execute. Chapter 5,"SQR Print," describes how to use the SQR Print to create report files for eachsupported printer type.

    SQR Execute, a run-time version for SQR programs. Chapter 4, "SQR Execute,"describes how to use SQR Execute to run a precompiled SQR report.

    About SQR

    SQR is a specialized programming language for data access, data manipulation, andfor reporting. SQR supports the full complement of SQL commands. Using SQR, youcan build complex report procedures that execute subsidiary SQL statementsconditionally, implementing either nested or hierarchical program logic. An SQRprogram can execute multiple queries.

    SQR features include:

    Flexibility and scalability of client-server architecture

    Comprehensive facilities for combined report processing and SQL processing

    Multiple platform portability

    Multiple RDBMS portability

  • SQR Language Reference SQR 4.3

    2 Introduction

    You can design custom SQR reports by defining the page size, headings, footings, andlayout. You can create many different kinds of reports, including tabular (withmultiple detail lines), single or multiple page, and form letters. With SQR, you candisplay data in columns, produce special formats such as mailing labels, and createoutput electronic transfer or for creating pages on laser printers and phototypesetters.

    After creating reports you can view the page layout in printer-independent format,create printer-specific files, or create HTML output for use on the Internet, Intranet, orExtranet. You can also run a separate program for generating reports precompiled bySQR.

    SQR may also be used as a high-level programming language that allows you to addprocedural logic and control to SQL queries and commands. You can use SQR to writeother types of applications, including database manipulation and maintenance, tableload and unload, and interactive query and display. In fact, many SQR applications arewritten to perform many functions other than generating reports.

  • SQR 4.3 SQR Language Reference

    Introduction 3

    The SQR Program Structure

    SQR reads commands from a file that you create. It then processes these commandsand creates your report. The program file consists of sections that are delimited byBEGIN-section and END-section commands. The following is a general outline of anSQR program.

    The SETUP section describes overall characteristics of the report.

    BEGIN-SETUP {setup commands}...END-SETUP

    The HEADING and FOOTING sections specify what is printed in the heading andfooting on each page of the report.

    BEGIN-HEADING {heading_lines} {heading commands}...END-HEADINGBEGIN-FOOTING {footing_lines} {footing commands}...END-FOOTING

    The PROGRAM section executes the procedures contained in the report.

    BEGIN-PROGRAM {commands}...END-PROGRAM

    The PROCEDURE section accomplishes the tasks associated with producing the report.

    BEGIN-PROCEDURE {procedure_name} {procedure commands}...END-PROCEDURE

  • SQR Language Reference SQR 4.3

    4 Introduction

    Syntax Conventions

    SQR syntax uses the following conventions.

    Symbol Description

    { } Braces enclose required items.

    [ ] Square brackets enclose optional items.

    ... An ellipsis shows that the preceding parameter can berepeated.

    | A vertical bar separates alternatives within brackets, braces,or parentheses.

    ! An exclamation point begins a single-line comment thatextends to the end of the line. Each comment line mustbegin with an exclamation point.

    ' A single quote starts and ends a literal text constant or anyargument that has more than one word.

    , A comma separates multiple arguments.

    ( ) Parentheses must enclose an argument or element.

    BOLD UPPERCASE SQR commands and arguments are specified in bolduppercase.

    Italic Information and values that you must supply are specifiedin italics.

    Table 1. Syntax Conventions

    Rules for Entering Commands

    These are the rules for entering SQR commands:

    All SQR commands are case insensitive.

    Command names and arguments are separated by at least one space or tabcharacter.

    Each command may consist of multiple lines, but each new command must beginon a new line.

    You can break a line in any position between words except within a quotedstring.

    You can optionally use a hyphen (-) at the end of a line to indicate that thefollowing line is a continuation.

  • SQR 4.3 SQR Language Reference

    Introduction 5

    An exclamation point begins a single-line comment that extends to the end of theline. Each comment line must begin with an exclamation point.

    If you need to display the ! or ' in your report, type it twice to indicate it is text. Forexample, DON'T is typed, DON''T. This rule does not apply in the DOCUMENTsection used in form letter reports.

    The SQR Command Line

    SQR contains several components, such as the SQR Language, SQR Execute, and SQRPrint. Each of these has a command-line interface. The command-line interface of SQRExecute is explained in Chapter 4. The command-line interface of SQR Print isexplained in Chapter 5.

    To begin running SQR, enter the following command. (If you are running underWindows, invoke SQRW rather than SQR.)

    SQR [program] [connectivity] [flags ...] [args ...] [@file ...]

    where:

    Argument Description

    program The name of your program. The default file type or extension is .SQR.If entered as "?" or omitted, SQR prompts you for the report programname. On UNIX-based systems, if your shell uses the questioncharacter as a WILD CARD character, you must precede it with abackslash (\).

    connectivity The information needed by SQR to connect to the database. If enteredas "?" or omitted, SQR prompts you for it.

    DB2 Ssname/SQLid is the subsystem name and SQLauthorization id to use.

    Informix Database is the name of the database to use.Ingres Database[/STAR][/Username] is the name of the

    database to use and an optional user name.

    ODBC Data_Source_Name/[Username]/[Password] is the nameyou give to the ODBC driver when you setup thedriver, your user name, and password for thedatabase. This port has been certified against DB2 andMicrosoft SQL Server.

    Table 2. SQR Command-Line Arguments

  • SQR Language Reference SQR 4.3

    6 Introduction

    Argument Description

    Oracle [Username]/[Password[@Database]] is youruser name and password for the database. Optionally,you can specify the connection string for the database(e.g. @B:ORASERVER).

    Rdb [Username]/[Password[@Database]] is youruser name and password for the database. Optionally,you can specify the connection string for the database(e.g. @B:RDBSERVER).

    Red Brick Data_Source_Name/[Username]/[Password] is the nameyou give to the Red Brick supplied driver when yousetup the driver, your user name, and password forthe database.

    SQLBase [Database]/[Username]/[Password] is thename of the database to use, your user name andpassword for the database.

    SYBASE Username/[Password] is your user name andpassword for the database.

    flags Any of the flags listed in Table 3.args... Arguments used by SQR while the program is running. Arguments

    listed here are used by the ASK and INPUT commands rather thanprompting the user. Arguments must be entered on the command linein the same sequence they are expected by the program first allASK arguments in order and then INPUT arguments.

    @file... File containing program arguments, one argument per line.Arguments listed in the file are processed one at a time first all ASKarguments in order and then INPUT arguments. The command linearguments program, connectivity, and args can be specified in this filefor non-Windows platforms.

    Table 2. SQR Command-Line Arguments (continued)

  • SQR 4.3 SQR Language Reference

    Introduction 7

    SQR supports a number of command-line flags. Each flag begins with a dash (-). Flagswith arguments must be followed immediately by the argument with no interveningspace.

    Flag Description

    -A Causes the output to be appended to an existing output file of thesame name. If the file does not exist, a new one is created. This isuseful when you want to run the same report more than once butonly want to create a single output file.

    -Bnn (ODBC, Oracle, SYBASE CT-Lib) Indicates the number of rows tobuffer each time data is retrieved from the database. The default is10 rows. Additional memory is required to buffer more rows. Youcan enhance performance by using additional memory to buffermore rows. Regardless of the setting, all rows are retrieved. Whenused on the command line, -B controls the setting for allBEGIN-SELECT commands. Within a program, eachBEGIN-SELECT command may also have its own -B flag forfurther optimization.

    -BURST:{xx} Specifies the type of bursting to be performed.

    -BURST:T generates the Table of Contents file only.

    -BURST:S generates the report output according to the symbolicTable of Contents entries set in the program with the TOC-ENTRYcommand's "level" argument. In -BURST:S[ {l} ], {l} is the level atwhich to burst upon. The setting -BURST:S is equivalent to-BURST:S1

    -BURST:P generates the report output by report page numbers. In-BURST:P[ {l} , {s} [, {s}] ] ] , {l} is the number of logical reportpages that each .HTM file will contain and {s} is the page selection:{n}, {n}-{m}, -{m}, or {n}-. The setting -BURST:P is equivalent to-BURST:P0,1- when using -PRINTER:HT or -BURST:P1 whenusing -PRINTER:EH.

    Note: -BURST:P and -BURST:S require -PRINTER:EH or-PRINTER:HT. The Page range selection feature of -BURST:Prequires -PRINTER:HT. -BURST:T requires -PRINTER:HT

    -C (Windows) Specifies that the Cancel dialog box appears while theprogram is running so you can easily terminate the programexecution.

    -CB (Windows, Callable SQR) Forces the communication box to beused.

    Table 3. SQR Command-Line Flags

  • SQR Language Reference SQR 4.3

    8 Introduction

    Flag Description

    -Dnn (non-Windows) Causes SQR to display the report output on theterminal at the same time it is being written to the output file. nn isthe maximum number of lines to display before pausing. If nonumber is entered after -D, the display will scroll continuously.The printer type must be LP or the display is ignored. If theprogram is producing more than one report, the display is for thefirst report only.

    -DBdatabase (SYBASE) Causes the SQR program to use the specified database,overriding any USE command in the SQR program.

    -DEBUG[xxx] Causes lines preceded by #DEBUG to be compiled. Without thisflag, these lines are ignored. See #DEBUG on page 76 for moreinformation.

    -DNT: {xx} Specifies the default behavior for numeric variables. The value forxx can be INTEGER, FLOAT, DECIMAL, or V30. To specify aprecision for DECIMAL, append it with a colon delimiter (:)forexample, -DNT:DECIMAL:20. See the DEFAULT argument forDECLARE-VARIABLE for a detailed explanation. The DEFAULTargument in the DECLARE-VARIABLE command will takeprecedence, if used.

    -E[file] Causes error messages to be directed to the named file, or to thedefault file program.err. If no errors occur, no file is created.

    -EH_CSV Generate a {report}.csv file from the report data.

    Note: This flag is only applicable when the -PRINTER:EH flag isspecified.

    -EH_CSV:file Associate the CSV icon with the specified file.

    Note: This flag is only applicable when the -PRINTER:EH flag isspecified.

    -EH_Icons:dir Specifies the directory where the HTML should look for thereferenced icons.

    Note: This flag is only applicable when the -PRINTER:EH flag isspecified.

    Table 3. SQR Command-Line Flags (continued)

  • SQR 4.3 SQR Language Reference

    Introduction 9

    Flag Description

    -EH_Scale:{nn} Sets the scaling factor from 50 to 200

    Note: This flag is only applicable when the -PRINTER:EH flag isspecified.

    -F[library| file(member)] (AS400) Overrides the default output file name library/lis(program).The default action places the lis in a source file called lis in thesame library as the member {program}. To use the current library,specify -F without an argument. To change the name of the outputfile, specify -F with the new name. If the new name does notspecify a library, the file will be created in the current library. Theoutput file is not created until data is actually printed on the page.If no data is printed, no output file will be created.To specify an alternate filename: -FSQRDIR/LIS(file)

    -F[file | directory] Overrides the default output file name, program.lis. The defaultaction places the program.lis in the same directory as theprogram.sqr file. To use the current directory, specify -F without anargument. To change the name of the output file, specify -F withthe new name. If the new name does not specify a directory, thefile will be created in the current directory. The output file is notcreated until data is actually printed on the page. If no data isprinted, no output file will be created.

    The following table shows how to specify the file name anddirectory for different operating systems.

    OperatingSystem

    DirectoryCharacter

    Example

    VMS ] or : -FSYS$USER:[REPORTS] or

    -FSYS$SCRATCH:

    UNIX / -F$HOME/reports/

    Prime/Stratus > -Freports>

    MVS ( -FDSN:SQR.REPORTS(

    -Gfile_mode (VM) Specifies the file mode to use when the report output file iscreated. See the VM C Library manual, "afopen" function, for acomplete description of all the valid keywords and values.

    -Gfile_attributes (VMS, OpenVMS) Specifies the file attributes to use when thereport output file is created. Up to 10 sets of attributes may bespecified, separated by commas (,). See the VAX C Library manual,"creat" function, for a complete description of all the validkeywords and values.

    Table 3. SQR Command-Line Flags (continued)

  • SQR Language Reference SQR 4.3

    10 Introduction

    Flag Description

    -GPRINT=YES | NO (MVS) -GPRINT=YES causes SQR's report output file to haveANSI control characters written to the first column of each recordof the file. -GPRINT=NO causes the control characters to beomitted.

    -Idir_list Specifies the list of directories that SQR will search whenprocessing the #INCLUDE directive if the include file does notexist in the current directory and no path was specified for the file.The directory names must be separated by either commas (,) orsemicolons (;). For UNIX-based systems, if your shell usessemicolons as command delimiters, you must precede eachsemicolon with a backslash (\). Always append the directorycharacter to the end of each directory name. See the -F flag for a listof directory characters by operating system. For example, underUNIX:sqr myreport sammy/baker -I/home/sqr/inc/,/usr/sqr/incl/

    -ID (non-Windows) Causes the copyright banner to be displayed onthe console.

    -KEEP Creates .SPF file output in addition to .LIS files, for each report thatyour program generates.

    -LL{s | d}{c | i} LOAD-LOOKUP: s = SQR, d = DB, c = case-sensitive,i = case-insensitive See the LOAD-LOOKUP command.

    -LOCK{RR | CS | RO | RL | XX}

    (SQLBase) Defines the types of locking (isolation level) for thesession. See the SQLBase manual for a full explanation of thedifferent isolation levels. See also BEGIN-SELECT on page 47.

    -Mfile Defines a startup file containing sizes to be assigned to variousinternal parameters extra small or large or complex reports.

    -NOLIS Prevents the creation of .LIS files. Instead, .SPF files are created.

    -NR (SQLBase) Specifies that the No Recovery mode is used whenconnecting to the database.

    -O[file] Directs log messages to the specified file or to program.log if no fileis specified. By default, the file sqr.log is used in the currentworking directory.

    -P (MVS, AS400) Suppresses printer control characters fromcolumn 1.

    -PB (Informix) Causes column data to retain trailing blanks.

    -Proleid[/rolepass] (Ingres) The role identifier used to associate permissions with SQR.

    Table 3. SQR Command-Line Flags (continued)

  • SQR 4.3 SQR Language Reference

    Introduction 11

    Flag Description

    -PRINTER:xx Causes printer type xx to be used when creating output files.

    xx Printer Type Example

    EH Enhanced HTML -PRINTER:EH

    HP HP LaserJet -PRINTER:HP

    HT HTML -PRINTER:HT

    LP Line Printer -PRINTER:LP

    PS PostScript -PRINTER:PS

    WP Windows -PRINTER:WP

    Types LP, HP, and PS produce files with the .LIS extension. TypesEH and HT produce .htm file output. Type HT produces version2.0 HTML files with the report content inside of tags. Type EH produces reports in which content is fully formattedwith version 3.0 or 3.2 HTML tags. On Windows systems, the WPextension sends the output to the printer. If you also want tocreate an .SPF file, use -KEEP.

    -RS Saves the program in a run-time file. The program is scanned andchecked for correct syntax. Queries are validated. Then, theexecutable version is saved in a file with the name program.sqt.Note that ASK variables are not prompted for after compilation.

    -RT Uses the run-time file saved with the -RS flag. All syntax andquery checking is skipped and processing begins immediately.Note that ASK variables are not prompted for after compilation.

    -S Requests that the status of all cursors be displayed at the end of thereport run. Status includes the text of each SQL statement, numberof times each was compiled and executed, and the total number ofrows selected. This information can be used for debugging SQLstatements and enhancing performance and tuning.

    -SORTnn (SQLBase) Specifies the size of the sort buffer in characters.

    -Tnn Specifies that you want to test your report for nn pages. AllORDER BY clauses in SELECT statements are ignored to save timeduring testing. If the program is producing more than one report,SQR stops after the specified number of pages defined for the firstreport have been output.

    Table 3. SQR Command-Line Flags (continued)

  • SQR Language Reference SQR 4.3

    12 Introduction

    Flag Description

    -T{B} (AS400/DB2, SYBASE CT-Lib, ODBC) Trims trailing blanks fromdatabase character columns.

    (MVS/DB2) Prevents SQR from removing trailing blanks fromdatabase character columns.

    -T{B|Z|BZ|ZB} (MVS/DB2) -TB prevents SQR from removing trailing blanks fromdatabase character columns. -TZ prevents SQR from removingtrailing zeros from the decimal portion of numeric columns. -TBZor -TZB prevents both.

    (AS400/DB2) -TB trims trailing blanks from database charactercolumns. -TZ prevents SQR from removing trailing zeros from thedecimal portion of numeric columns. -TBZ or -TZB is legal.

    -Uusername (Ingres) Specifies the user name. This overrides the user namespecified in the connectivity string.

    -Vserver (SYBASE) Uses the named server.

    -XB (non-Windows) Suppresses the SQR banner and the "SQR... End ofRun" message.

    -XC (Callable SQR) Suppresses the database commit when the reporthas finished running.

    -XCB (Windows) Do not use the communication box. Requests for inputwill be made in Windows dialog boxes.

    -XL Prevents SQR from logging on to the database. Programs run inthis mode cannot contain any SQL statements. -XL lets you runSQR without accessing the database. You still must supply at leastan empty slash (/) on the command line as a placeholder for theconnectivity information.

    For example: sqr myprog / -xl-XMB (Windows) Disables the error message display so that a program

    can be run without interruption by error message boxes. Errormessages will only be sent to an .err file. See the -E flag for moreinformation.

    -XNAV Prevents SQR from creating the 'Navigation Bar' in.HTM filesgenerated with -PRINTER:HT. This will occur when only a single.HTM file is produced. Multiple .HTM files generated from asingle report will always contain the 'Navigation Bar'.

    -XP (SYBASE) Prevents SQR from creating temporary storedprocedures. See BEGIN-SELECT on page 47 for more information.

    -XTB Preserves the trailing blanks in an .LIS file at the end of a line.

    Table 3. SQR Command-Line Flags (continued)

  • SQR 4.3 SQR Language Reference

    Introduction 13

    Flag Description

    -XTOC Prevents SQR from generating the Table of Contents for the report.This flag is ignored when either -PRINTER:EH or -PRINTER:HTis also specified.

    -ZIF{file} Sets the full path and name of the SQR initialization file, SQR.INI.

    -ZIV Invokes the SPF Viewer after generating program.spf file. This flagimplicitly invokes the -KEEP flag to create program.spf. In case ofmultiple output files, only the first report file will be passed to theViewer.

    -ZMF{file} Specifies the full path and name of the SQR error message file,sqrerr.dat.

    Table 3. SQR Command-Line Flags (continued)

    SQR Data Elements

    SQR data elements include columns, variables, and literals. Each begins with a specialcharacter which denotes the type of data element.

    Columns are fields defined in the database.

    & begins a database column or expression name. It can be any type (for example,character, number, or date) and, except for dynamic columns and database oraggregate functions, is declared automatically for columns defined in a query.

    Variables are storage places for text or numbers that you define and manipulate.

    $ begins a text or date variable.

    # begins a numeric variable.

    @ begins a variable name for a marker location. Marker locations are used toidentify positions to begin for printing inside a BEGIN-DOCUMENTparagraph.

    Literals are text or numeric constants.

    A single quote begins and ends a text literal. For example, 'Hello'.

    0-9 begin any numeric literals. Numerals that include digits with an optionaldecimal point and leading sign are acceptable numeric literals. For example,-543.21. Numeric literals can also be expressed in scientific form. For example,1.2E5.

  • SQR Language Reference SQR 4.3

    14 Introduction

    The following rules apply to variables:

    Variables may be given almost any name of any length, for example,$state_name or #total_cost.

    Variable names are case insensitive. That is, you may use a name as uppercase onone line and lowercase on the next; both refer to the same variable.

    Variables are initialized to null (text and date) or zero (numeric).

    Text variables can grow to any length, within the memory limitations of yourcomputer.

    Numeric variables can be one of three types: FLOAT, INTEGER, or DECIMAL.See the DECLARE-VARIABLE command for a full explanation.

    Variables and columns are known globally throughout a report, except if used ina local procedure (one with arguments or declared with the LOCAL argument) inwhich case they are known in that procedure only. See the BEGIN-PROCEDUREcommand for a full explanation.

    When creating multiple reports, the variables apply to the current report.

    SQR uses the following pre-defined, or reserved, variables:

    Variable Description#current-column The current column on the page.

    $current-date The current date-time on the local machine when SQR starts runningthe program.

    #current-line The current line on the page. This value is the physical line on thepage, not the line in the report body. See SQR User's Guide.

    Line numbers are referenced in PRINT and other SQR commandsused for positioning data on the page. Optional page headings andfootings, defined with BEGIN-HEADING and BEGIN-FOOTINGcommands, have their own line sequences. Line 2 of the heading isdifferent from line 2 of the report body or footing.

    #end-file Set to one (1) if end of file occurs when reading a flat filesee theREAD command.

    #page-count The current page number.

    #return-status Value to be returned to the operating system when SQR exits. May beset in your report. #return-status is initialized to the "success" returnvalue for the operating system.

    #sql-count The count of rows affected by a DML statement (INSERT, UPDATE,or DELETE). This is equivalent to ROWCOUNT in Oracle andSybase.

    Table 4. SQR Reserved Variables

  • SQR 4.3 SQR Language Reference

    Introduction 15

    Variable Description$sql-error The text message from the database explaining an error. This variable

    is rewritten when a new error is encountered.

    #sql-status The status value from the database after each query is compiled orexecuted. The status value is database dependent, for both successand failure. (For Oracle, the "V2" status is returned.)

    $sqr-database,{sqr-database}

    The database type for which SQR was compiled. Valid values are:

    DB2INFORMIXINGRES

    ODBCORACLEREDBRICK

    SQLBASESYBASE

    $sqr-dbcs,{sqr-dbcs}

    Specifies whether SQR recognizes double-byte character strings. Thevalue may be either YES or NO.

    $sqr-encoding,{$sqr-encoding}

    The value of the ENCODING environment variable when SQR isinvoked. The value can be ASCII, JEUC, or SJIS. ASCII is the default.

    $sqr-hostname,{$sqr-hostname}

    This variable contains the name of the computer on which SQR iscurrently executing.

    $sqr-locale The name of the current locale being used. A '+' at the end of thename indicates an argument used in the locale has changed.

    #sqr-max-lines The maximum number of lines as determined by the layout. When anew report is selected, this variable will be automatically updated toreflect the new layout.

    #sqr-max-columns The maximum number of columns as determined by the layout.When a new report is selected, this variable will be automaticallyupdated to reflect the new layout.

    #sqr-pid The process ID of the current SQR process. #sqr-pid is unique foreach run of SQR. This variable is useful in creating unique temporarynames.

    $sqr-platform,{sqr-platform}

    The hardware/operating system type for which SQR was compiled.Valid values are:

    WINDOWS-NTVMVMS

    MVSUNIX

    $sqr-program The name of the SQR program file.

    $sqr-ver The text string shown with the -ID flag.

    $username The database user name specified on the command line.

    $sqr-report The name of the report output file. $sqr-report reflects the actualname of the file to be used (as specified by the -F flag orNEW-REPORT command).

    Table 4. SQR Reserved Variables (continued)

  • SQR Language Reference SQR 4.3

    16 Introduction

    Viewing Sample Reports

    To get a quick overview of how an SQR report looks, you can view the sample reportslisted in Chapter 7, "Sample Reports." These programs are stored in the SQR Serverdirectory SAMPLE. You can modify these reports to meet your needs. Completeexplanations of the commands used in the reports are included in Chapter 2, "SQRCommand Reference."

  • Chapter 2 SQR Command Reference 17

    2 SQR Command ReferenceThis chapter describes each SQR command, and provides examples of use.

    The commands in this chapter follow the conventions listed in the Introduction, anduse the following terms and abbreviations:

    Abbreviation Description Example

    txt_col Text column that can be retrieved from adatabase.

    &address

    num_col Numeric column that can be retrievedfrom a database.

    &price

    date_col Date or datetime column that can beretrieved from a database.

    &date1

    txt_var String variable that is defined in aprogram.

    $your_name

    num_var Numeric variable that is defined in aprogram.

    #total_cost

    date_var A variable explicitly defined as a datevariable.

    $date1

    any_lit A literal of any type. 'abc'

    12

    any_var A variable of any type. $string

    #number

    $date

    any_col A column of any type. &string

    &number

    &date

    txt_lit Text literal that is defined in a program. 'CompanyConfidential'

    num_lit Numeric literal that is defined in aprogram.

    12345.67

    int_lit Integer literal that is defined in aprogram.

    12345

    Table 5. Syntax Abbreviation Conventions

  • SQR Language Reference SQR 4.3

    18 Chapter 2 SQR Command Reference

    Abbreviation Description Example

    nn Integer literal that is used as anargument to a command.

    123

    position The position qualifier, which consists ofthe line, column, and lengthspecification.

    The minimum position, (), means to usethe current line and column position onthe page for the length of the field beingprinted.

    (5,10,30)

    Table 5. Syntax Abbreviation Conventions (continued)

  • SQR Language Reference ADD

    Chapter 2 SQR Command Reference 19

    ADD

    Function

    Adds one number to another.

    Syntax

    ADD { src_num_lit | _var | _col } TO dst_num_var [ ROUND = nn ]

    Arguments

    src_num_lit | _var | _col A numeric source value. Is added to the contents ofdst_num_var.

    dst_num_var A numeric destination variable. Contains the result after execution.

    ROUND Rounds the result to the specified number of digits to the right of thedecimal point. For float variables this value can be from 0 to 15. For decimalvariables this value can be from 0 to the precision of the variable. For integervariables this argument is not appropriate.

    Description

    The source value is added to the destination variable and the result is placed in thedestination. The source is always first, the destination is always second.

    When dealing with money-related values (dollars and cents) you should use decimalvariables rather than float variables. This is because float variables are stored as doubleprecision floating point numbers, and small inaccuracies can appear when addingmany numbers in succession. This is due to the way floating point numbers arerepresented by different hardware and software implementations, and to inaccuracieswhich can be introduced when converting between floating point and decimal.

    Examplesadd 10 to #counteradd #counter to #new_countadd &price to #total round=2

  • ADD SQR 4.3

    20 Chapter 2 SQR Command Reference

    See Also

    See the LET command for information on complex arithmetic expressions.

  • SQR Language Reference ALTER-LOCALE

    Chapter 2 SQR Command Reference 21

    ALTER-LOCALE

    Function

    Selects a locale or changes locale parameters used for printing date, numeric, andmoney data and for data accepted by the INPUT command. A locale is a set ofpreferences for language, currency, and the presentation of charts and numbers.

    Syntax

    ALTER-LOCALE[ LOCALE = { txt_lit | _var | DEFAULT | SYSTEM } ][ NUMBER-EDIT-MASK = { txt_lit | _var | DEFAULT | SYSTEM } ][ MONEY-EDIT-MASK = { txt_lit | _var | DEFAULT | SYSTEM } ][ DATE-EDIT-MASK = { txt_lit | _var | DEFAULT | SYSTEM } ][ INPUT-DATE-EDIT-MASK = { txt_lit | _var |DEFAULT | SYSTEM } ][ MONEY-SIGN = { txt_lit | _var | DEFAULT | SYSTEM } ][ MONEY-SIGN-LOCATION = { txt_var |

    DEFAULT | SYSTEM | LEFT | RIGHT } ][ THOUSAND-SEPARATOR = { txt_lit | _var | DEFAULT | SYSTEM } ][ DECIMAL-SEPARATOR = { txt_lit | _var | DEFAULT | SYSTEM } ][ DATE-SEPARATOR = { txt_lit | _var | DEFAULT | SYSTEM } ][ TIME-SEPARATOR = { txt_lit | _var | DEFAULT | SYSTEM } ][ EDIT-OPTION-NA = { txt_lit | _var | DEFAULT | SYSTEM } ][ EDIT-OPTION-AM = { txt_lit | _var | DEFAULT | SYSTEM } ][ EDIT-OPTION-PM = { txt_lit | _var | DEFAULT | SYSTEM } ][ EDIT-OPTION-BC = { txt_lit | _var | DEFAULT | SYSTEM } ][ EDIT-OPTION-AD = { txt_lit | _var | DEFAULT | SYSTEM } ][ DAY-OF-WEEK-CASE = { txt_var |

    DEFAULT | SYSTEM | UPPER | LOWER | EDIT | NO-CHANGE } ][ DAY-OF-WEEK-FULL = ( { txt_lit1 | _var1 } ... { txt_lit7 | _var7 } ) ][ DAY-OF-WEEK-SHORT = ( { txt_lit1 | _var1 } ... { txt_lit7 | _var7 } ) ][ MONTHS-CASE = { txt_var |

    DEFAULT | SYSTEM | UPPER |LOWER | EDIT | NO-CHANGE } ][ MONTHS-FULL = ( { txt_lit1 | _var1} ... {txt_lit12 | _var12 } ) ][ MONTHS-SHORT = ( { txt_lit1 | _var1 } ... { txt_lit12 | _var12 } ) ]

  • ALTER-LOCALE SQR 4.3

    22 Chapter 2 SQR Command Reference

    Arguments

    Note Many of the settings can have a value of DEFAULT or SYSTEM. For a givensetting, when DEFAULT is specified, the value is retrieved from the correspondingsetting of the default locale as identified in the [Default-Settings] section of theSQR.INI file. Similarly, when the keyword SYSTEM is specified, the value isretrieved from the corresponding setting of the system locale. The system localecan be altered using the ALTER-LOCALE command; however, it cannot be definedin the SQR.INI file.

    LOCALE - Specifies the name of the locale to use. This name must be defined in theSQR.INI file. If this field is omitted, then the current locale will be used. The localename is case-insensitive and is limited to the following character set: A-Z, 0-9,underscore, or hyphen. The current locale can be determined by printing thereserved variable $sqr-locale.

    NUMBER-EDIT-MASK - Specifies the numeric edit mask to use when the keywordNUMBER is specified in a PRINT, MOVE, SHOW, or DISPLAY command.

    MONEY-EDIT-MASK - Specifies the numeric edit mask to use when the keywordMONEY is specified in a PRINT, MOVE, SHOW, or DISPLAY command.

    DATE-EDIT-MASK - The default date edit mask that is used when the keywordDATE is used with the DISPLAY, MOVE, PRINT, or SHOW command, or theLET functions datetostr() or strtodate().

    INPUT-DATE-EDIT-MASK - The default date format to use with the INPUTcommand when TYPE=DATE is specified with the command or the input variableis a date variable.

    MONEY-SIGN - Specifies the character(s) which will replace the '$' or other currencysymbol used in edit masks.

    MONEY-SIGN-LOCATION - Specifies where the MONEY-SIGN character(s) will beplaced. Valid values are LEFT and RIGHT.

    THOUSAND-SEPARATOR - Specifies the character which will replace the ',' editcharacter.

  • SQR Language Reference ALTER-LOCALE

    Chapter 2 SQR Command Reference 23

    DECIMAL-SEPARATOR - Specifies the character which will replace the '.' editcharacter.

    DATE-SEPARATOR - Specifies the character which will replace the '/' character.

    TIME-SEPARATOR - Specifies the character which will replace the ':' character.

    EDIT-OPTION-NA - Specifies the character(s) which will be used with the 'na' option.

    EDIT-OPTION-AM - Specifies the character(s) which will be used to replace 'AM'.

    EDIT-OPTION-PM - Specifies the character(s) which will be used to replace 'PM'.

    EDIT-OPTION-BC - Specifies the character(s) which will be used to replace 'BC'.

    EDIT-OPTION-AD - Specifies the character(s) which will be used to replace 'AD'.

    DAY-OF-WEEK-CASE - Specifies how the case for the DAY-OF-WEEK-FULL orDAY-OF-WEEK-SHORT entries are affected when used with the format codes'DAY' or 'DY'. Valid values are UPPER, LOWER, EDIT, and NO-CHANGE.UPPER and LOWER force the output to either all uppercase or lowercase, ignoringthe case of the format code in the edit mask. Use EDIT to follow the case asspecified with the format code in the edit mask. Use NO-CHANGE to ignore thecase of the format code and output the day of week as explicitly listed in theDAY-OF-WEEK-FULL or DAY-OF-WEEK-SHORT entries.

    DAY-OF-WEEK-FULL - Specifies the full names for the days of the week. SQRconsiders the first day of the week to be Sunday. All seven days must be specified.

    DAY-OF-WEEK-SHORT - Specifies the abbreviated names for the days of the week.SQR considers the first day of the week to be Sunday. All seven abbreviations mustbe specified.

    MONTHS-CASE - Specifies how the case for the MONTHS-FULL orMONTHS-SHORT entries are affected when used with the format codes'MONTH' or 'MON'. Valid values are UPPER, LOWER, EDIT, and NO-CHANGE.UPPER and LOWER force the output to either all uppercase or lowercase, ignoringthe case of the format code in the edit mask. Use EDIT to follow the case asspecified with the format code in the edit mask. Use NO-CHANGE to ignore thecase of the format code and output the month as explicitly listed in theMONTHS-FULL or MONTHS-SHORT entries.

  • ALTER-LOCALE SQR 4.3

    24 Chapter 2 SQR Command Reference

    MONTHS-FULL - Specifies the full names for the months of the year. SQR considersthe first month of the year to be January. All twelve months must be specified.

    MONTHS-SHORT - Specifies the abbreviated names for the months of the year. SQRconsiders the first month of the year to be January. All twelve abbreviations mustbe specified.

    Description

    The 'SYSTEM' locale represents the behavior of older versions of SQR prior to version4.0. When you install SQR version 4.0 or later, the default locale is set to 'SYSTEM'.This provides upwards compatibility for older SQR programs.

    The 'SYSTEM' locale settings are described in the following table:

    Keyword Value

    NUMBER-EDIT-MASK The PRINT command prints 2 digits to the right of thedecimal point and left justifies the number in the field. TheMOVE, SHOW, and DISPLAY commands format thenumber with 6 digits to the right of the decimal point andleft justifies the number.

    MONEY-EDIT-MASK SQR uses the same default as the NUMBER-EDIT-MASKkeyword.

    DATE- EDIT-MASK SQR uses the default database date format in Table 32 onpage 225.

    INPUT-DATE-EDIT-MASK

    SQR uses a default date edit mask with the INPUTcommand. See Table 20 on page 221 for a listing of thedate edit mask.

    MONEY-SIGN $MONEY-SIGN-LOCATION

    LEFT

    THOUSAND-SEPARATOR

    ,

    DECIMAL-SEPARATOR .

    DATE-SEPARATOR /TIME-SEPARATOR ':'

    EDIT-OPTION-NA 'n/a'

    EDIT-OPTION-AM 'am'

    EDIT-OPTION-PM 'pm'

    Table 6. 'SYSTEM' Locale Settings

  • SQR Language Reference ALTER-LOCALE

    Chapter 2 SQR Command Reference 25

    Keyword Value

    EDIT-OPTION-BC 'bc'

    EDIT-OPTION-AD 'ad'

    DAY-OF-WEEK-CASE EDIT

    DAY-OF-WEEK-FULL ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday','Friday', 'Saturday')

    DAY-OF-WEEK-SHORT ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat')

    MONTHS-CASE EDIT

    MONTHS-FULL ('January', 'February', 'March', 'April', 'May', 'June', 'July','August', 'September', 'October', 'November', 'December')

    MONTHS-SHORT ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct','Nov', 'Dec')

    Table 6. 'SYSTEM' Locale Settings (continued)

    Examples!! The following program segments will illustrate the various! ALTER-LOCALE features.!begin-setup declare-variable date $date $date1 $date2 $date3 end-declareend-setup

    ! ! Set default masks ! alter-locale number-edit-mask = 9,999,999.99 money-edit-mask = $999,999,999.99 date-edit-mask = Mon DD, YYYY

    let #value = 123456 let $edit = Mon DD YYYY HH:MI:SS let $date = strtodate(Jan 01 1995 11:22:33, $edit) show With NUMBER option #Value = #value number show With MONEY option #Value = #value money show Without NUMBER option #Value = #value show With DATE option $Date = $date date show Without DATE option $Date = $date

  • ALTER-LOCALE SQR 4.3

    26 Chapter 2 SQR Command Reference

    Produces the following output:

    With NUMBER option #Value = 123,456.00With MONEY option #Value = $ 123,456.00Without NUMBER option #Value = 123456.000000With DATE option $Date = Jan 01, 1995Without DATE option $Date = 01-JAN-95

    ! ! Reset locale to SQR defaults and assign a multi-character ! money-sign. ! alter-Locale locale = System money-sign = AU$ ! Australian dollars

    let #value = 123456 show #value edit $999,999,999,999.99 show #value edit $$$$,$$$$999,999.99

    Produces the following output:

    AU$ 123,456.00 AU$123,456.00

    ! ! Move the money-sign to the right side of the value. Note ! the leading space. ! alter-locale money-sign = AU$ ! Australian dollars money-sign-location = right

    let #value = 123456 show #value edit $999,999,999,999.99 show #value edit $$$$,$$$$999,999.99

    Produces the following output:

    123,456.00 AU$ 123,456.00 AU$

    ! ! Reset locale to SQR defaults and flip the thousand and ! decimal separator characters. ! alter-locale locale = System thousand-separator = . decimal-separator = ,

    let #value = 123456 show #value edit 999,999,999,999.99

  • SQR Language Reference ALTER-LOCALE

    Chapter 2 SQR Command Reference 27

    Produces the following output:

    123.456,00

    ! ! Reset locale to SQR defaults and change the date and time ! separators ! alter-locale locale = System date-separator = - time-separator = .

    let $edit = Mon/DD/YYYY HH:MI:SS let $date = strtodate(Jan/01/1995 11:22:33, $edit) show $date edit :$edit

    Produces the following output:

    Jan-01-1995 11.22.33

    ! ! Reset locale to SQR defaults and change the text used with ! the edit options na, am, pm, bc, ad ! alter-locale locale = System edit-option-na = not/applicable edit-option-am = a.m. edit-option-pm = p.m. edit-option-bc = b.c. edit-option-ad = a.d.

    let $value = let $edit = Mon DD YYYY HH:MI let $date1 = strtodate(Jan 01 1995 11:59, $edit) let $date2 = strtodate(Feb 28 1995 12:01, $edit) show $value edit 999,999,999,999.99Na show $date1 edit Mon DD YYYY HH:MI:SS PM show $date2 edit Mon DD YYYY HH:MI:SS pm

    Produces the following output:

    Not/ApplicableJan 01 1995 11:59:00 A.M.Feb 28 1995 12:01:00 p.m.

  • ALTER-LOCALE SQR 4.3

    28 Chapter 2 SQR Command Reference

    ! ! Input some dates using the system locale and ! output using other locales from the SQR.INI file. ! alter-locale locale = System let $date1 = strtodate(Jan 01 1995, Mon DD YYYY) let $date2 = strtodate(Feb 28 1995, Mon DD YYYY) let $date3 = strtodate(Mar 15 1995, Mon DD YYYY) show System: show show $date1 edit Month DD YYYY is $date1 edit Day show $date2 edit Month DD YYYY is $date2 edit Day show $date3 edit Month DD YYYY is $date3 edit Day alter-locale locale = German show show German: show show $date1 edit DD Month YYYY ist $date1 edit Day show $date2 edit DD Month YYYY ist $date2 edit Day show $date3 edit DD Month YYYY ist $date3 edit Day alter-locale locale = Spanish show show Spanish: show show $date1 edit DD Month YYYY es $date1 edit Day show $date2 edit DD Month YYYY es $date2 edit Day show $date3 edit DD Month YYYY es $date3 edit Day

    Produces the following output:

    System:

    January 01 1995 is SundayFebruary 28 1995 is TuesdayMarch 15 1995 is Wednesday

    German:

    01 Januar 1995 ist Sonntag28 Februar 1995 ist Dienstag15 Mrz 1995 ist Mittwoch

    Spanish:

    01 enero 1995 es domingo28 febrero 1995 es martes15 marzo 1995 es mircoles

  • SQR Language Reference ALTER-LOCALE

    Chapter 2 SQR Command Reference 29

    See Also

    See the DISPLAY, LET, MOVE, PRINT, and SHOW commands. See Chapter 8,SQR.INI.

  • ALTER-PRINTER SQR 4.3

    30 Chapter 2 SQR Command Reference

    ALTER-PRINTER

    Function

    Alters printer parameters at run time.

    Syntax

    ALTER-PRINTER[ POINT-SIZE = { point_size_num_lit | _var } ][ FONT-TYPE = { font_type | txt_var } ][ SYMBOL-SET = { symbol_set_id | txt_var } ][ FONT = { font_int_lit | _var } ][ PITCH = { pitch_num_lit | _var } ]

    Arguments

    POINT-SIZE Specifies the new font point size.

    FONT-TYPE Specifies the new font type. Enter PROPORTIONAL or FIXED.

    SYMBOL-SET Specifies the new symbol set identifier.

    FONT Specifies the new font as a number. (For example, 3 = Courier and 4 =Helvetica.)

    PITCH Specifies the new pitch in characters per inch.

    See Table 14 on page 96 for more information on these arguments.

    Description

    The ALTER-PRINTER command may be placed in any part of an SQR program exceptand SETUP section.

  • SQR Language Reference ALTER-PRINTER

    Chapter 2 SQR Command Reference 31

    ALTER-PRINTER attempts to change the attributes of the "current" printer for the"current" report. If an attribute does not apply to the "current" printer, it is ignored.For example, ALTER-PRINTER will be ignored if it specifies proportional fonts for areport printed on a line printer. When your program is creating multiple reports andthe printer is shared by another report, the attributes are changed for that report aswell.

    Examples

    Change the font and symbol set for the current printer.

    alter-printerfont=4 ! Helveticasymbol-set=12U ! PC-850 Multilingual

    If the output is printed to a PostScript printer, the SYMBOL-SET argument is ignored;however, if the .SPF file is kept (see the -KEEP command line flag) and later printed onan HP LaserJet, the symbol set 12U may be used.

    See Also

    See the DECLARE-PRINTER command for more information.

  • ARRAY-ADD SQR 4.3

    32 Chapter 2 SQR Command Reference

    ARRAY-ADD

    ARRAY-DIVIDE

    ARRAY-MULTIPLY

    ARRAY-SUBTRACT

    Function

    These four commands perform arithmetic on one or more elements in an array.

    Syntax

    ARRAY-ADD { src_num_lit | _var | _col } ... TO dst_array_name ( element_lit | _var | _col ) [ field [ ( occurs_lit | _var | _col ) ] ] ...

    ARRAY-DIVIDE { src_num_lit | _var | _col } ... INTOdst_array_name ( element_int_lit | _var | _col ) [ field [ ( occurs_lit | _var | _col ) ] ] ...

    ARRAY-MULTIPLY { src_num_lit | _var | _col } ... TIMES dst_array_name ( element_int_lit | _var | _col ) [ field [ ( occurs_lit | _var | _col ) ] ] ...

    ARRAY-SUBTRACT { src_num_lit | _var | _col } ... FROMdst_array_name ( element_int_lit | _var | _col ) [ field [ ( occurs_lit | _var | _col ) ] ] ...

    Arguments

    src_num_lit | _var | _col Source value(s) are added to, divided into, multiplied times,or subtracted from the respective destination array fields. All variables must benumeric in type.

    dst_array_name ( element_int_lit | _var | _col ) [ field [ ( occurs_lit | _var | _col ) ] ] Destination array field(s) contain the results after the operation. All variables mustbe numeric in type.

  • SQR Language Reference ARRAY-ADD

    Chapter 2 SQR Command Reference 33

    Description

    The following information applies to the array arithmetic commands:

    The array must first be created using the CREATE-ARRAY command.

    The four array arithmetic commands perform on one or more source numbers,placing the result into the corresponding field in the array.

    Array element and field occurrence numbers can be numeric literals (123) ornumeric variables (#j) and can be from zero (0) to one less than the size of thearray.

    If fields are not listed, the results are placed into consecutively defined fields inthe array. If fields are listed, results are placed into those fields, at the specifiedoccurrence of the field. If an occurrence is not specified the zero'th (0) occurrenceis used.

    All fields must be of the type NUMBER, DECIMAL, FLOAT, or INTEGER. Theycannot be of type DATE, CHAR, or TEXT.

    If division by zero is attempted, a warning message is displayed, the result field isunchanged, and SQR continues executing.

    Examples

    In the following example, &salary and #comm are added to the first two fields definedin the emps array. The #j'th element of the array is used.

    array-add &salary #comm to emps(#j)In the following example, #lost, #count, and 1 are subtracted from the fields loses, tot andsequence of the #j2'th element of the stats array.

    array-subtract #lost #count 1 from stats(#j2) loses tot sequenceIn the following example, occurrences 0 through 2 of the field p in the #i'th element ofthe percentages array are each multiplied by 2.

    array-multiply 2 2 2 times percentages(#i) p(0) p(1) p(2)

    In the following example, the #i2'th occurrence of the salesman field of the #j'th elementof the commissions array is divided by 100.

    array-divide 100 into commissions(#j) salesman(#i2)

  • ARRAY-ADD SQR 4.3

    34 Chapter 2 SQR Command Reference

    The following is an example of how the ARRAY-ADD command can be used in anSQR program.

    begin-setup! declare arrayscreate-array name=emps size=1 ! one row needed for this example

    field=Salary:number=35000 ! initialize to 35,000field=Comm:number=5000 ! initialize to 5,000

    end-setup

    begin-programdo Mainend-program

    begin-procedure Main local! Show original contents of the arrays, then the modified arrays! array-add! retrieve values from the only row of array "emps"get #sal #com FROM emps(0) Salary Commprint Array-Add (+1, 1)

    print Add 1000 to each column (+1, 1)print Salary (+1, 3) bold underlineprint Comm (,25) bold underline

    print #sal (+1, 1) moneyprint #com (,22) money

    let #salary = 1000let #commission = 1000let #j = 0 ! address the array row with variable "#j"! Add 1000 (in variables) to each column of row 0 (the 1st and

    only row)array-add #salary #commission TO emps(#j)! retrieved the new "added" valuesget #sal #com FROM emps(0) Salary Commprint #sal (+1,1) moneyprint #com (,22) moneyend-procedure

    See Also

    See the CREATE-ARRAY command for information on creating an array. See theCLEAR-ARRAY command for information on clearing or initializing an array. See alsothe GET, PUT, and LET commands for information on using arrays.

  • SQR Language Reference ASK

    Chapter 2 SQR Command Reference 35

    ASK

    Function

    Retrieves for a compile-time substitution variable. The retrieval may be by user input,command-line arguments, or as entries in the @file on the command line (see thesection on command-line flags for more information).

    Syntax

    ASK substitution_variable [ prompt ]

    Arguments

    substitution_variable Is the variable to be used as the substitution variable.

    prompt Is an optional literal text string to be displayed as a prompt if the value for thesubstitution variable is not entered on the command line or in an argument file.

    Description

    The value of the substitution variable will replace the reference variable in theprogram. Variables are referenced by enclosing the variable name in braces, forexample, '{state_name}. If the substitution variable is text or date, the bracketsmust be surrounded by single quotes. Substitutions are made as the program iscompiled and are saved in the SQT file. Each variable can be referenced multiple times.

    ASK is used only in the SETUP section and must appear prior to any substitutionvariable references.

    The ASK command cannot be broken across program lines.

  • ASK SQR 4.3

    36 Chapter 2 SQR Command Reference

    Examples

    In the following example, state takes the value entered by the user in response to theprompt "Enter state for this report".

    begin-setup ask state Enter state for this reportend-setup ...

    begin-selectname, city, state, zipfrom customers where state = {state}end-select

    See Also

    See the INPUT command for information on input at run time and the chapter "Usingthe SQR Command Line" in the SQR Users Guide.

  • SQR Language Reference BEGIN-DOCUMENT

    Chapter 2 SQR Command Reference 37

    BEGIN-DOCUMENT

    Function

    Begins a DOCUMENT paragraph. A document paragraph allows you to write free-form text to create form letters, invoices, etc.

    Syntax

    BEGIN-DOCUMENT positionEND-DOCUMENT

    Arguments

    position Is the location on the page where the document will begin. The position canbe fixed or relative to the current position.

    Description

    Database columns, SQR variables, and document markers can be referenced within adocument. Their location in the document determines where they will be printed onthe page. You should not use tabs inside a document paragraph. To indent text or fielduse the spacebar. Note also that if the variables being printed inside a documentparagraph are variable in length, you may want to manipulate the variable outside theDOCUMENT paragraph.

    Note A document must be executed before you can reference its document markers.Since documents can be printed at relative positions on the page, the actuallocation of a document marker may not be known by SQR until the document itselfhas been executed.

    Examplesbegin-document (1,1).bDear $firstname ...

    end-document

  • BEGIN-DOCUMENT SQR 4.3

    38 Chapter 2 SQR Command Reference

    See Also

    See the END-DOCUMENT command and the chapter "Creating Form Letters" in theSQR User's Guide for a full example of the BEGIN-DOCUMENT command.

  • SQR Language Reference BEGIN-FOOTING

    Chapter 2 SQR Command Reference 39

    BEGIN-FOOTING

    Function

    Begins the FOOTING section.

    Syntax

    BEGIN-FOOTING footing_lines_int_lit[ FOR-REPORTS = ( report_name1 [, report_namei ] ... ) ][ FOR-TOCS = ( toc_name1 [, toc_namei ] ... ) ]

    END-FOOTING

    Arguments

    footing_lines_int_lit Is the number of lines to be reserved at the bottom of each page.

    FOR-REPORTS Specifies the reports to which this footing applies. This is requiredonly for a program with multiple reports. If you are writing a program thatproduces a single report, you can ignore this argument.

    FOR-TOCS Specifies the Table of Contents to which this heading applies.

    Description

    The FOOTING section defines and controls information to be printed at the bottom ofeach page.

    The report_name must be defined in a DECLARE-REPORT paragraph. If you do notuse DECLARE-REPORT, the footing will be applied to all reports. You can alsospecify FOR-REPORTS=(ALL). Note that the parentheses are required.

    The toc_name must be defined in a DECLARE-TOC paragraph. You can also specifyFOR-TOCS=(ALL). Note that the parentheses are required.

  • BEGIN-FOOTING SQR 4.3

    40 Chapter 2 SQR Command Reference

    More than one BEGIN-FOOTING section can be specified; however, there can be onlyone for each report. A BEGIN-FOOTING section with FOR-REPORTS=(ALL) can befollowed by other BEGIN-FOOTING sections for specific reports, which override theALL setting.

    The BEGIN-FOOTING section can be shared between reports and Table of Contents.

    You can print outside the footing area of the report, that is into the body area, from thefooting, but you cannot print into the footing area from the body.

    Examplesbegin-footing 2 for-reports=(customer, summary) print Company Confidential (1,1,0) center page-number (2,37,0)end-footingbegin-footing 2 ! For all reports print Division Report (1,1,0) center page-number (2,37,0)end-footingbegin-footing 2 for-tocs=(all) print Table of Contents (2,1) let $page = roman(#page-count) ! ROMAN numerals print $page (,64)end-footing

    See Also

    See the DECLARE-LAYOUT command for more information on page layout. See alsothe DECLARE-REPORT command for more information on programs with multiplereports. See the DECLARE-TOC command for more information on Table of Contents.See the END-FOOTING command.

  • SQR Language Reference BEGIN-HEADING

    Chapter 2 SQR Command Reference 41

    BEGIN-HEADING

    Function

    Begins a HEADING section.

    Syntax

    BEGIN-HEADING heading_lines_int_lit[ FOR-REPORTS = ( report_name1 [, report_namei ] ... ) ][ FOR-TOCS = ( toc_name1 [, toc_namei ] ... ) ]

    END-HEADING

    Arguments

    heading_lines_int_lit Is the number of lines to be reserved at the top of each page.

    FOR-REPORTS Specifies the reports to which this heading applies. This is requiredonly for a program with multiple reports. If you are writing a program thatproduces a single report, you can ignore this argument.

    FOR-TOCS Specifies the Table of Contents to which this heading applies.

    Description

    The HEADING section defines and controls information to be printed at the top of eachpage.

    The report_name must be defined in a DECLARE-REPORT paragraph. If you do notuse DECLARE-REPORT, the heading will be applied to all reports. You can alsospecify FOR-REPORTS=(ALL). Note that the parentheses are required.

    More than one BEGIN-HEADING section can be specified; however, there can be onlyone for each Table of Contents. A BEGIN-HEADING section with FOR-TOCS=(ALL)can be specified followed by other BEGIN-HEADING sections for specific Table ofContents, which override the ALL setting.

    The toc_name must be defined in a DECLARE-TOC paragraph. You can also specifyFOR-TOCS=(ALL). Note that the parentheses are required.

  • BEGIN-HEADING SQR 4.3

    42 Chapter 2 SQR Command Reference

    More than one BEGIN-HEADING section can be specified; however, there can be onlyone for each report. A BEGIN-HEADING section with FOR-REPORTS=(ALL) can bespecified followed by other BEGIN-HEADING sections for specific reports, whichoverride the ALL setting.

    The BEGIN-HEADING section can be shared between reports and Table of Contents.

    You can print outside the heading area of the report, that is into the body area, from theheading, but you cannot print into the heading area from the body.

    Examplesbegin-heading 2 ! Use 2 lines forprint $current-date (1,1) edit MM/DD/YY ! heading, print Sales for the Month of (1,30) ! 2nd is blank. print $month ()end-headingbegin-heading 2 for-tocs=(all) print Table of Contents (1,1) bold centerend-heading

    See Also

    See the DECLARE-LAYOUT command for more information on page layout. See alsothe DECLARE-REPORT command for more information on programs with multiplereports. See the DECLARE-TOC command for more information on Table of Contents.See the END-HEADING command.

  • SQR Language Reference BEGIN-PROCEDURE

    Chapter 2 SQR Command Reference 43

    BEGIN-PROCEDURE

    Function

    Begins a procedure. A procedure is one of the most powerful parts of the SQRlanguage. It is used to modularize functions and provide standard execution control.

    Syntax

    BEGIN-PROCEDURE procedure_name [ LOCAL | ( arg1 [, argi ] ... ) ]END-PROCEDURE

    Arguments

    procedure_name Specifies a unique name for this proced


Recommended