You are on page 1of 136

INFORMIX-4GL

Quick Syntax

Version 6.0
April 1994
Part No. 000-7609
2

Published by INFORMIX® Press Informix Software, Inc.


4100 Bohannon Drive
Menlo Park, CA 94025

The following are worldwide trademarks of Informix Software, Inc., or its subsidiaries, registered in the United States of
America as indicated by an “®,” and in numerous other countries worldwide:

INFORMIX® and C-ISAM®.

The following are worldwide trademarks of the indicated owners or their subsidiaries, registered in the United States of
America as indicated by an “®,” and in numerous other countries worldwide:

X/OpenCompany Ltd.: UNIX®; X/Open®


Adobe Systems Incorporated: Post Script®

Some of the products or services mentioned in this document are provided by companies other than Informix. These
products or services are identified by the trademark or servicemark of the appropriate company. If you have a question
about one of those products or services, please call the company in question directly.

ACKNOWLEDGMENTS
The following people contributed to this version of INFORMIX-4GL Quick Syntax:
Documentation Team: Adam Barnett, Kaye Bonney, Lisa Braz, Tom Houston, Liz Knittel, Jerry Pope
Technical Contributors: Jonathan Leffler, Sally Cox

Copyright © 1981-1994 by Informix Software, Inc. All rights reserved.

No part of this work covered by the copyright hereon may be reproduced or used in any form or by any means—graphic,
electronic, or mechanical, including photocopying, recording, taping, or information storage and retrieval systems—
without permission of the publisher.

RESTRICTED RIGHTS LEGEND

Software and accompanying materials acquired with United States Federal Government funds or intended for use within
or for any United States federal agency are provided with “Restricted Rights” as defined in DFARS 252.227-7013(c)(1)(ii) or
FAR 52.227-19.
Table of
Contents

INFORMIX-4GL
Quick Syntax
Introduction 5
Syntax Conventions 6

Basics 9
Data Types 10
4GL Arithmetic Operators 10
Boolean Operators 10
4GL Relational Operators 10
Global Constants and Variables 11
Built-In Functions 11
Operators 11
Library Functions 12
Display Attributes 15
Command-Line Syntax 16

4GL Statements 19
Types of SQL Statements 20
Other Types of 4GL Statements 21
4GL Statement Segments 37

4GL Forms 47
Form Specification Syntax 48
Attributes 50

Reports 55
Report Specification Syntax 56
Report Execution Statements 59

SQL Statements 61
SQL Segments 91
Stored Procedure Language Statements 105
4

SQLCA Record 113

Interactive Debugger Commands 117


Command-Line Syntax 119
4GL Interactive Debugger Command Segments 126

Environment Variables 129

Default Key Assignments 133


Introduction
6 Syntax Conventions

This Guide presents a quick reference to the material listed in the following table. For
a full discussion of each topic, refer to the corresponding documentation.

Topic Reference Documentation Section

Data types INFORMIX-4GL Reference Chapter3


(DEFINE)
Built-in functions and operators INFORMIX-4GL Reference Chapter 4
4GL statements INFORMIX-4GL Reference Chapter 3
SQL statements
4.1 servers: Informix Guide to SQL: Reference Chapter 6
6.0 servers: Informix Guide to SQL: Syntax, Version 6.0 Chapter 1
Stored Procedure Language (SPL)
6.0 servers: Informix Guide to SQL: Syntax, Version 6.0 Chapter 2
4GL forms INFORMIX-4GL Reference Chapter 5
Reports INFORMIX-4GL Reference Chapter 6
SQLCA record structure INFORMIX-4GL Reference Chapter 2
NewEra Debugger commands Guide to the INFORMIX-4GL Interactive Chapter 9
Debugger
Environment variables INFORMIX-4GL Reference Appendix D

This Guide shows syntax that must be prepared before you can include it in a 4GL
program. You must prepare any SQL statement introduced later than the 4.1 server
release. These statements are indicated in this manual by the following icon:
6.0
SE

To use these statements, such as CREATE TRIGGER, you must:


1. Store the SQL statement as a character string.
2. Set up the statement for execution by means of the PREPARE statement (see
page 79).
3. Process the statement by means of the EXECUTE statement (see page 75).

Syntax Syntax diagrams describe the format of SQL, SPL, and 4GL statements and Debugger
Conventions commands, including alternative forms of them, required and optional parts of
them, and so forth. Syntax diagrams have their own conventions, which are defined
in detail and illustrated in this section.
Each syntax diagram displays the sequences of required and optional elements that
are valid in a statement or command. Briefly:
• All keywords are shown in uppercase letters for ease of identification, though
you need not enter them that way.
• Words for which you must supply values are in italics.
• All boldface characters are literals.
Syntax Conventions 7

Each diagram begins at the upper left with a keyword and ends at the upper
right with a vertical line. Between these points, you can trace any path that does
not stop or back up. Each path describes a valid form of the statement. Except
for separators in loops (see page 8), which the path approaches counterclock-
wise from the right, the path always approaches elements from the left and con-
tinues to the right.
Along a path, you may encounter the following elements:
KEYWORD You must spell a word in uppercase letters exactly as shown;
however, you can use either uppercase or lowercase letters when you
enter it.
(.,;+*-/) All other characters are literal symbols that you must enter exactly as
shown.
' ' " " Single and double quotes are literal symbols that you must enter as
shown.
variable A word in italics represents a value that you must supply. The nature
of the value is explained fully in the appropriate reference manual.

Scope A reference in a box represents a subdiagram on the same page (if no


Scope List page number is supplied) or on a specified page. Imagine that the
List p. 148
subdiagram is spliced into the diagram at this point. (A synonym for
Named Value Named
“subdiagram” is “segment.”)
Value
If the term “(subset)” appears in the box below the name of the
segment being referenced, you should refer to the appropriate refer-
ence manual for further clarification.
The aspect ratio of the box is not significant. That is, the same
segment can be represented by boxes of different shapes, as in these
symbols for the Named Value segment.
OL A code in an icon is a signal warning you that this path is valid only
for certain database servers or under certain conditions. The codes
indicate the products or conditions that support the path. The follow-
ing codes are used:
6.0
SE Path requires the statement to be prepared (by using PRE-
PARE).
SE Path is valid only for INFORMIX-SE.
OL Path is valid only for INFORMIX-OnLine Dynamic Server.
+ Path is an Informix extension to ANSI standard SQL.
NLS Path is valid only if you are using NLS.
8 Syntax Conventions

ALL A shaded option is the default. Even if you do not explicitly type the
option, it will be in effect unless you choose another option.
Syntax enclosed in a pair of arrows indicates that this is a subdiagram.

The vertical line is a terminator and indicates that the statement is com-
plete.

IN
A branch below the main line indicates an optional path.
NOT
,
A loop indicates a path that can be repeated. Punctuation included in the
variable loop indicates the separator symbol for items in a list; when no symbol is
shown in the loop, as in the example below, a blank space or LINEFEED is
the separator.

A gate ( 3 ) in an option indicates that you can only use that option the
number of times indicated, even though it is within a larger loop.
3 column key

The grey labels and arrows in the following illustration identify the elements of
a syntax diagram for the INITIALIZE statement of 4GL.

Main Diagram Path Loop Reference Box Terminator

, ,
INITIALIZE variable LIKE Column
name List

Subdiagram record .* TO NULL


Title
Optional Required Variable
Column Branch Keyword Element
List
table . column
OL owner . *
database :
Segment
Icon @ server Punctuation Indicator

Elements of a syntax diagram


Basics

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
10 Data Types

Data Type Kind of Values Stored


Data Types ARRAY OF type Arrays of values of any other single data type.

BYTE Any kind of binary data.
CHAR Character strings of up to 32,767 ASCII characters.
CHARACTER (This keyword is a synonym for CHAR.)
DATE Points in time, specified as calendar dates.
DATETIME Points in time, specified as calendar dates and time-of-day.
DEC (This keyword is a synonym for DECIMAL.)
DECIMAL Fixed point numbers, of a specified scale and precision.
DOUBLE PRECISION (These keywords are a synonym for FLOAT.)
FLOAT Floating-point numbers, of up to 32-digit precision.
INT (This keyword is a synonym for INTEGER.)
INTEGER Whole numbers, from -2,147,483,647 to +2,147,483,647.
INTERVAL Spans of time in years and months, or else in smaller time units.
MONEY Currency amounts, with definable scale and precision.
NUMERIC (This keyword is a synonym for DECIMAL.)
REAL (This keyword is a synonym for SMALLFLOAT.)
RECORD Ordered sets of values, of any combination of 4GL data types.
➁SERIAL Same as INTEGER. Automatically assigned by the engine.
SMALLFLOAT Floating-point numbers, of up to 16-digit precision.
SMALLINT Whole numbers, from -32,767 to +32,767.
➀TEXT Character strings of any length.
➀VARCHAR Character strings of varying length, no greater than 255.

➀INFORMIX-OnLine Dynamic Server or other 4GL statements only. ➁SQL only.

Operator Symbol Operator Name Name of Result Precedence


4GL ** exponentiation power 12
Arithmetic mod modulus integer remainder 12
Operators * multiplication product 11
/ division quotient 11
+ addition sum 10
- subtraction difference 10

Boolean AND
OR
Operators
NOT

4GL Operator Symbol Operator Name Operator Symbol Operator Name


Relational < Less than != or <> Not equal to
Operators <= Not greater than >= Not less than
= or == Equal to > Greater than
Global Constants and Variables 11

FALSE SQLCA Record:


Global INT_FLAG SQLCODE
Constants NOTFOUND SQLERRM
and NULL SQLERRP
Variables SQLCODE SQLERRD
STATUS SQLAWARN
TRUE
QUIT_FLAG

Built-In ARG_VAL(int-expr) ERRORLOG(char-expr) NUM_ARGS( )


ARR_COUNT( ) FGL_DRAWBOX(height, †PERCENT(*)
Functions width,line,left-offset[,color])
ARR_CURR( ) SCR_LINE( )
†AVG(int-field) FGL_GETENV(char-expr) SET_COUNT(int-expr)
†COUNT(*) FGL_KEYVAL(char-expr) SHOWHELP(int-expr)
DOWNSHIFT(char-expr) FGL_LASTKEY( ) SQLEXIT( )
ERR_GET(int-expr) LENGTH(char-expr) STARTLOG(char-expr)
ERR_PRINT(int-expr) †MAX(int-field) †SUM(int-field)

ERR_QUIT(int-expr) †MIN(int-field) UPSHIFT(char-expr)


†Valid
only in REPORT blocks or in some SQL statements. Also, may be preceded by GROUP.

Color numbers and their meanings that can be used in FGL_DRAWBOX( ) are:
Number Color Number Color Number Color
0 White 3 Red 6 Blue
1 Yellow 4 Cyan 7 Black
2 Magenta 5 Green

Operators ASCII int-expr LENGTH(char-expr)


char-expr CLIPPED †LINENO

COLUMN integer MDY(int-expr, int-expr, int-expr)


CURRENT MONTH(date-expression)
CURRENT qualifier ORD(string-expr)
DATE †PAGENO

DATE (date-expression) int-expr SPACE


DAY(date-expression) int-expr SPACES
EXTEND(time-value) TIME Basics
EXTEND(time-value, qualifier) TODAY 4GL
FIELD_TOUCHED(field-list) int-expr UNITS time-keyword Forms
GET_FLDBUF(field-list) expression USING format-string Reports
expression IS NOT NULL WEEKDAY (date-expression) SQL
expression IS NULL †char-expr WORDWRAP SQLCA
INFIELD(field) YEAR (date-expression) Debugger
†Valid only in REPORT blocks. Variables
Keys
12 Library Functions

Popping Numbers
Library
Functions extern void popint(int *iv)
extern void popshort(short *siv)
Calling extern void poplong(long *liv)
C Functions extern void popflo(float *fv)
from 4GL extern void popdub(double *dfv)
extern void popdec(dec_t *decv)

Popping Characters
extern void popquote(char *qv, int len)
extern void popvchar(char *qv, int len)

Popping Dates and Times


extern void popdate(long *datv)
extern void popdtime(dtime_t *dtv, int qual)
extern void popinv(intrvl_t *iv, int qual)

Popping BYTE and TEXT


extern void poplocator(loc_t **blob)

Returning Values
extern void retint(int iv)
extern void retshort(short siv)
extern void retlong(long lv)
extern void retflo(float fv)
extern void retdub(double dfv)
extern void retdec(dec_t *decv)

extern void retquote(char *str0)


extern void retvchar(char *vc)

extern void retdate(long date)


extern void retdtime(dtime_t *dtv)

extern void retinv(intrvl_t *inv)

Pushing Values
extern void pushint(int iv)
extern void pushshort(short siv)
extern void pushlong(long liv)
extern void pushflo(float fv)
extern void pushdub(double dfv)
extern void pushdec(dec_t *decv, unsigned decp)
Calling 4GL Functions from C 13

Calling fgl_start(filename, argc, argv) initialize resources for the 4GL environment
4GL Functions char *filename;
from C int argc;
char *argv[];
fgl_call(funcname, nparams) call the 4GL function
char *funcname;
int nparams;
fgl_exitfm( ) reset terminal to character mode
fgl_end( ) free 4GL resources

Decimal deccvasc(cp, len, np) convert C char type to DECIMAL type


Functions char *cp;
int len;
dec_t *np;
dectoasc(np, cp, len, right) convert DECIMAL type to C char type
dec_t *np;
char *cp;
int len;
int right;
deccvint(integer, np) convert C int type to DECIMAL type
int integer;
dec_t *np;
dectoint(np, ip) convert DECIMAL type to C int type
dec_t *np;
int *ip;
deccvlong(lng, np) convert C long type to DECIMAL type
long lng;
dec_t *np;
dectolong(np, lngp) convert DECIMAL type to C long type
dec_t *np;
long *lngp;
deccvflt(flt, np) convert C float type to DECIMAL type
float flt;
dec_t *np;
Basics
dectoflt(np, fltp) convert DECIMAL type to C float type
4GL
dec_t *np;
float *fltp; Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
14 Decimal Functions

deccvdbl(dbl, np) convert C double type to DECIMAL type


double dbl;
dec_t *np;
dectodbl(np, dblp) convert DECIMAL type to C double type
dec_t *np;
double *dblp;
decadd(n1, n2, result) add two decimal numbers
dec_t *n1; (result = n1 + n2)
dec_t *n2;
dec_t *result;
decsub(n1, n2, result) subtract two decimal numbers
dec_t *n1; (result = n1 - n2)
dec_t *n2;
dec_t *result;
decmul(n1, n2, result) multiply two decimal numbers
dec_t *n1; (result = n1 * n2)
dec_t *n2;
dec_t *result;
decdiv(n1, n2, result) divide two decimal numbers
dec_t *n1; (result = n1 / n2)
dec_t *n2;
dec_t *result;
int deccmp(n1, n2) compare two decimal numbers
dec_t *n1;
dec_t *n2;
deccopy(n1, n2) copy a decimal number
dec_t *n1;
dec_t *n2;
char *dececvt(np, ndigit, decpt, sign) convert decimal value to ASCII string
dec_t *np;
int ndigit;
int *decpt;
int *sign;
char *decfcvt(np, ndigit, decpt, sign) convert decimal value to ASCII string
dec_t *np;
int ndigit;
int *decpt;
int *sign;
Display Attributes 15

Display
Attributes
ATTRIBUTE ,
Clause

ATTRIBUTE ( REVERSE )
BLACK BLINK

BLUE UNDERLINE

CYAN

GREEN

MAGENTA
BOLD
RED

WHITE DIM

YELLOW INVISIBLE

NORMAL
The ATTRIBUTE clause is used in these 4GL statements:

CONSTRUCT DISPLAY FORM INPUT ARRAY


DISPLAY ERROR MESSAGE
DISPLAY ARRAY INPUT PROMPT

For all ATTRIBUTE clauses and field attributes the following table shows the
effects of the color attributes on a monochrome monitor, as well as the effects
of the intensity attributes on a color monitor:

Color Monochrome Intensity Color


Attribute Display Attribute Display
WHITE NORMAL NORMAL WHITE
YELLOW BOLD BOLD RED
MAGENTA BOLD DIM BLUE
RED BOLD
CYAN DIM
GREEN DIM
Basics
BLUE DIM
BLACK DIM 4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
16 Command-Line Syntax

Command-
Line Syntax

c4gl

-ansi -e -a -anyerr

source.4gl

-args -o outfile esqlc.ec


source.c
obj.o
yourlib

-V

cfglgo fgiusr.c cfile .ec -o newfglgo

.c
.o

-V cfile

fglgo filename argument

-a -anyerr .4go
.4gi
-V

fglpc source

-ansi -a -anyerr -p pathname .4gl

-V

finderr msg_num
Command-Line Syntax 17

form4gl form-name

-q -l lines -c characters -V

-d form-name database- table-


name name

mkmessage in file out file

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
18 Command-Line Syntax
4GL Statements

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
20 Types of SQL Statements

INFORMIX-4GL supports the SQL language, but it is sometimes convenient to


distinguish between SQL statements and other 4GL statements:
• SQL statements operate on tables in the database.
• Other 4GL statements operate on variables in memory.
The SQL statements of 4GL can be divided into these functional categories.

Note: Not all of these SQL statements listed on this and the next page are directly supported by
4GL. If the statement or any part of its syntax is preceded by a 6.0 icon in its syntax diagram
later in this chapter, the statement must be prepared (by using the PREPARE statement). Prepar-
ing SQL statements is described in Chapter 3 of the INFORMIX-4GL Reference.

Types of SQL Data Definition Statements

SQL ALTER INDEX CREATE TABLE DROP TABLE


ALTER TABLE CREATE VIEW DROP VIEW
Statements CLOSE DATABASE DATABASE RENAME COLUMN
CREATE DATABASE DROP DATABASE RENAME TABLE
CREATE INDEX DROP INDEX
CREATE SYNONYM DROP SYNONYM

SQL Data Manipulation Statements


INSERT LOAD UNLOAD
DELETE SELECT UPDATE

SQL Cursor Manipulation Statements


CLOSE FETCH OPEN
DECLARE FLUSH PUT

SQL Query Optimization Information Statements


SET EXPLAIN SET OPTIMIZATION UPDATE STATISTICS

SQL Data Access Statements


GRANT REVOKE SET LOCK MODE
LOCK TABLE OL SET ISOLATION UNLOCK TABLE

SQL Data Integrity Statements


BEGIN WORK SE DROP AUDIT SE ROLLFORWARD DATABASE
SE CHECK TABLE SE RECOVER TABLE OL SET CONSTRAINTS
COMMIT WORK SE REPAIR TABLE OL SET LOG
SE CREATE AUDIT ROLLBACK WORK SE START DATABASE

Note: The data integrity statements marked with the SE symbol are supported
only by the INFORMIX-SE engine. Statements marked OL can only be used with the
INFORMIX-OnLine Dynamic Server engine.
Other Types of 4GL Statements 21

SQL Dynamic Management Statements


EXECUTE PREPARE
FREE

Other Types 4GL Definition and Declaration Statements


of 4GL DEFINE MAIN
FUNCTION REPORT
Statements
4GL Program Flow Control Statements
CALL FINISH REPORT OUTPUT TO REPORT
CASE FOR RETURN
CONTINUE FOREACH RUN
DATABASE GOTO START REPORT
END IF WHILE
EXIT LABEL

4GL Compiler Directives


DATABASE GLOBALS
DEFER WHENEVER

4GL Storage Manipulation Statements


INITIALIZE LOCATE
LET VALIDATE

4GL Screen Interaction Statements


CLEAR DISPLAY FORM OPEN WINDOW
CLOSE FORM ERROR OPTIONS
CLOSE WINDOW INPUT PROMPT
CONSTRUCT INPUT ARRAY SCROLL
CURRENT WINDOW MENU SLEEP
DISPLAY MESSAGE
DISPLAY ARRAY OPEN FORM

4GL Report Execution Statements


NEED PRINT
PAUSE SKIP
Most 4GL statements are not sensitive to whether the SE or the OnLine Basics
engine supports the application. Only the OnLine engine, however, can 4GL
store values in BYTE, TEXT, or VARCHAR columns, or can accept database: Forms
or database@system: as qualifiers to names of tables, views, or synonyms. Reports
SQL
SQLCA
Debugger
Variables
Keys
22 CALL

CALL function ( )
, ,
4GL Expression RETURNING Receiving
p. 39 Variable
p. 29

Case I: (single criterion)

CASE ( 4GL ) WHEN 4GL statement END CASE


Expression Expression
(subset) (subset)
p. 39 p. 39 EXIT CASE

OTHERWISE
Block
Case II: (multiple criteria)

WHEN 4GL Boolean statement


Expression
p. 40
EXIT CASE

OTHERWISE Block
OTHERWISE statement

EXIT CASE

CLEAR FORM

WINDOW window

SCREEN
,
Field Clause
p. 46

CLOSE FORM form

CLOSE WINDOW window


CONSTRUCT 23

CONSTRUCT CONSTRUCT
Variable
Clause ATTRIBUTE HELP
Clause number
p. 37
CONSTRUCT END
Form CONSTRUCT
Management
Block

CONSTRUCT ,
Variable Clause
variable ON Column List FROM Field Clause
p. 46

BY NAME variable ON Column List

,
Column List
column
Table Qualifier table .
p. 46

table . *
Table Qualifier
p. 46

CONSTRUCT
Form Management
Block
1 BEFORE CONSTRUCT statement

1 NEXT FIELD PREVIOUS


AFTER CONSTRUCT
, NEXT

BEFORE FIELD field Field


Clause
p. 46
AFTER FIELD
, CONTINUE CONSTRUCT

ON KEY ( key ) EXIT CONSTRUCT Basics


4GL
Forms
CONTINUE keyword Reports
SQL
SQLCA
CURRENT WINDOW IS window
Debugger
SCREEN Variables
Keys
24 DEFER

DEFER INTERRUPT

QUIT

,
DEFINE variable Data Type Declaration
p. 37

Case I: (output in the Line mode overlay)


,
DISPLAY DISPLAY
Value
COLUMN left-offset

Case II: (in a specified line of the current window)


,
DISPLAY AT line, left-offset
Value
ATTRIBUTE
Clause
p. 37

Case III: (in a screen form)


, ,
,
DISPLAY TO Field
Value Clause
, p. 46 ATTRIBUTE
Clause
variable p. 37
BY NAME

DISPLAY Value
value

CLIPPED

USING "format string "


ASCII number

DISPLAY ARRAY record array TO screen array . *


ATTRIBUTE ON KEY
Clause Block END
p. 37 p. 25 DISPLAY
DISPLAY FORM 25

ON KEY Block
,
ON KEY ( key name ) statement

EXIT DISPLAY

DISPLAY FORM form

ATTRIBUTE Clause
p. 37

END keyword

These are valid keywords in the END statement:


CASE FOREACH INPUT PROMPT
CONSTRUCT FUNCTION MAIN REPORT
DISPLAY GLOBALS MENU WHILE
FOR IF

,
ERROR "string"
variable ATTRIBUTE
Clause
p. 37

Case I: (terminating a program)


EXIT PROGRAM

( exit code )
exit code
Case II: (terminating a statement)
keyword

These are valid keywords in Case II of the EXIT statement:


CASE FOR MENU Basics
CONSTRUCT FOREACH PROMPT
DISPLAY INPUT WHILE 4GL
Forms
Reports
FINISH REPORT report SQL
SQLCA
Debugger
Variables
Keys
26 FOR

FOR counter = start TO finish statement END FOR

STEP increment CONTINUE FOR

EXIT FOR

FOREACH cursor statement END FOREACH


, CONTINUE
FOREACH
INTO Variable
List EXIT
FOREACH

Variable List
,
variable
. .*
record . first THROUGH record . last

, THRU

array [ 3 Integer ]
Expression
p. 41

FUNCTION function ( ) END FUNCTION


,
argument ) DEFINE statement
Statement
p. 24 RETURN
Statement
p. 35

Case I: (declaring and exporting variables)


,
GLOBALS DEFINE Statement END GLOBALS
p. 24

Case II: (importing variables)

"filename"
GOTO 27

GOTO label name

IF 4GL Boolean THEN statement END IF


Expression
p. 40
ELSE statement

,
INITIALIZE Variable LIKE table .column
List
Table
Qualifier
.*
p. 46
TO NULL

,
Variable List
variable

. .*
record . first THROUGH record . last
, THRU

array [ 3 Integer ]
Expression
p. 41

INPUT Binding
Clause
p. 28 ATTRIBUTE HELP number
Clause INPUT Form END INPUT
p. 37 Management
Block

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
28 INPUT ARRAY

, ,
Binding Clause
variable FROM Field Clause
field
(subset)
, WITHOUT DEFAULTS p. 46

BY NAME variable

WITHOUT DEFAULTS

INPUT Form ,
Management Block

BEFORE FIELD Field Clause statement


p. 46
AFTER INPUT NEXT FIELD field
, NEXT

ON KEY ( key ) EXIT PREVIOUS


CONTINUE INPUT

Acceptable values of key (in lowercase or uppercase letters) for the ON KEY block are:

ACCEPT HELP NEXT or RETURN or ENTER


DELETE INSERT NEXTPAGE RIGHT
DOWN INTERRUPT PREVIOUS or TAB
ESC or ESCAPE LEFT PREVPAGE UP
F1 through F64
CONTROL-char (except A, D, H, I, J, L, M, R, or X)
Built-in functions that access field buffers and keystroke buffers:
Built-In Funtion Description
FIELD_TOUCHED(field) Returns TRUE when the user has made a change to screen field.
GET_FLDBUF(field-list) Returns the character values of the contents of one or more fields.
FGL_LASTKEY( ) Returns an INTEGER value corresponding to the most recent keystroke.
INFIELD(field) Returns TRUE if field is the name of the current screen field.

INPUT ARRAY Binding


Clause
ATTRIBUTE HELP number
Clause INPUT ARRAY END INPUT
p. 37 Form
Management
Block

Binding Clause
program array FROM screen array .*
WITHOUT DEFAULTS
LABEL 29

INPUT ARRAY
Form Management ,
Block
BEFORE FIELD Field Clause statement
p. 46
AFTER INPUT NEXT FIELD Field Clause
field
p. 46
DELETE
NEXT
INSERT EXIT
PREVIOUS
ROW
CONTINUE INPUT
,
ON KEY ( key )

For acceptable values of key, see p. 28. For built-in functions that access field buffers
and keystroke buffers, see p. 28.
Built-in functions that keep track of the relative states of the screen cursor, the pro-
gram array, and the screen array:

Function Description
ARR_CURR( ) Returns the number of the current record of the program array.
ARR_COUNT( ) Returns the current number of records in the program array.
SCR_LINE( ) Returns the number of the current line within the screen array.
SET_COUNT(filled-rows) Sets the initial value of ARR_COUNT( ) to filled-rows.

LABEL label identifier :

,
LET Receiving = 4GL Expression
Variable p. 39

blob = NULL
destination .* = source . *

Receiving Variable Basics


simple variable 4GL
Forms
record . Reports
, SQL
SQLCA
array [ 3 Integer Expression ] Debugger
p. 41
Variables
Keys
30 LOAD

LOAD FROM "filename" insert


variable
file variable DELIMITER "character"
INSERT
delimiter Clause

INSERT Clause
INSERT INTO table

Table Qualifier ,
p.46
( column )

,
LOCATE BYTE or TEXT IN MEMORY
Variable
FILE "filename"
variable

BYTE or TEXT
Variable
variable

. .*
record .first THROUGH record . last
, THRU

array [ 3 integer ]

MAIN statement END MAIN

EXIT PROGRAM
DEFINE DATABASE
Statement Statement
p. 72 DEFER Statement
p. 24 p. 24

MENU "title " MENU Control Block END MENU

variable
MESSAGE 31

MENU Control
Block
BEFORE MENU statement

COMMAND Block NEXT OPTION option name


,
SHOW OPTION option
name
HIDE ALL
CONTINUE MENU
EXIT MENU

COMMAND Block

COMMAND option name


, option
3 HELP
description number
KEY ( key )

,
MESSAGE "string"
variable ATTRIBUTE
Clause
p. 37

OPEN FORM form FROM "filename"

OPEN WINDOW window AT top-line , left-offset WITH height ROWS , width COLUMNS

FORM "filename" OPEN


WINDOW
ATTRIBUTE
variable Clause
p. 32

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
32 OPEN WINDOW

OPEN WINDOW ,
Attribute Clause
ATTRIBUTE ( REVERSE )
WHITE BORDER

YELLOW COMMENT LINE Reserved


Line
MAGENTA FORM LINE Position

RED MENU LINE

CYAN MESSAGE LINE

GREEN PROMPT LINE

BLUE
BLACK NORMAL

BOLD

DIM

Attribute Default Setting


color Default foreground color on your terminal
REVERSE No reverse video
BORDER No border
PROMPT LINE line value FIRST (=1)
MESSAGE LINE line value FIRST + 1 (=2)
MENU LINE line value FIRST (=1)
FORM LINE line value FIRST + 2 (=3)
COMMENT LINE line value LAST - 1 (for the 4GL screen)
LAST (for all other 4GL windows)

Reserved Line
Position
FIRST

+
integer

-
LAST
OPTIONS 33

,
OPTIONS COMMENT LINE FIRST

ERROR +
FORM number
MENU
-
MESSAGE
LAST
PROMPT

ACCEPT KEY key

DELETE

INSERT

NEXT

PREVIOUS

HELP FILE "filename"

DISPLAY ATTRIBUTE OPTIONS


ATTRIBUTE
Clause
INPUT WRAP p. 34

NO WRAP

FIELD ORDER UNCONSTRAINED

CONSTRAINED ON

SQL INTERRUPT OFF

Clause Default
COMMENT LAST - 1 for the 4GL screen
LINE LAST for all other 4GL windows
ERROR LINE LAST line of the 4GL screen
FORM LINE FIRST + 2 or line 3 of the current 4GL window
MENU LINE FIRST line of the 4GL window
MESSAGE LINE FIRST + 1 or line 2 of the current 4GL window
Basics
PROMPT LINE FIRST line of the 4GL window
4GL
ACCEPT KEY ESCAPE
Forms
DELETE KEY F2
Reports
INSERT KEY F1
SQL
NEXT KEY F3
SQLCA
PREVIOUS KEY F4
Debugger
HELP KEY CONTROL-W
Variables
HELP FILE None
Keys
34 OUTPUT TO REPORT

OPTIONS ,
ATTRIBUTE Clause
ATTRIBUTE ( BLINK )
BLACK REVERSE

BLUE UNDERLINE

CYAN

GREEN BOLD

MAGENTA DIM

RED INVISIBLE

WHITE NORMAL

YELLOW FORM

WINDOW

,
OUTPUT TO REPORT report ( 4GL Expression )
p. 39

blob

,
PROMPT "string" FOR response

variable ATTRIBUTE HELP number


Clause
p. 37 CHAR

ATTRIBUTE
Clause
p. 37 ,
ON KEY ( key ) statement END PROMPT
For values for key, see p. 28.
REPORT 35

REPORT report ( ) FORMAT END REPORT


, Section
p. 58
argument ) DEFINE
Statement
p. 24

OUTPUT ORDER BY
Section Section
p. 56 p. 57

RETURN
,
4GL Expression
p. 39

RUN "command "


character variable RETURNING integer variable

WITHOUT WAITING

,
SCROLL Field Clause DOWN
p. 46
UP BY lines

SLEEP Integer
Expression
p. 41

START REPORT report

TO "filename"
PRINTER

PIPE "command " Basics


variable 4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
36 UNLOAD

UNLOAD TO "filename" select variable

file variable DELIMITER "character"


SELECT
delimiter variable Statement
p. 82

,
VALIDATE Variable LIKE table .column
List
Table .*
Qualifier
p. 46

,
Variable List
variable

. .*
record . first THROUGH record . last
, THRU

array [ 3 Integer ]
Expression
p. 41

WHENEVER NOT FOUND CONTINUE

SQLERROR GO TO : label
+ + + +
ANY ERROR GOTO label

SQLWARNING STOP

WARNING CALL function

WHILE 4GL Boolean statement END WHILE


Expression
p. 40 EXIT WHILE

CONTINUE WHILE
ATTRIBUTE Clause 37

4GL
Statement
Segments
ATTRIBUTE ,
Clause
ATTRIBUTE ( REVERSE )
BLACK BLINK

BLUE UNDERLINE

CYAN

GREEN

MAGENTA
BOLD
RED

WHITE DIM

YELLOW INVISIBLE

NORMAL

Data Type
Declaration
LIKE table . column
Table Qualifier
p. 46
4GL Data Type

4GL Data Type

4GL Simple Data Type


p. 38
ARRAY Data Type
p. 38
RECORD Data Type
p. 39
TEXT Basics
4GL
BYTE
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
38 4GL Simple Data Type

4GL Simple
Data Type

INTEGER

INT

SMALLINT

DECIMAL (16)
DEC ( precision ) , scale
NUMERIC , scale ( precision ,2 )
MONEY (16, 2)
FLOAT

DOUBLE PRECISION ( precision )


SMALLFLOAT

REAL

DATE

DATETIME DATETIME Qualifier


p. 44

INTERVAL INTERVAL Qualifier


p. 45

CHARACTER (1)
CHAR ( size ) , reserve size
VARCHAR ( maximum size ,0 )

Array Data Type ,


ARRAY [ 3 size ] OF 4GL Simple Data Type
p. 38

RECORD Data Type


p. 39
BYTE
TEXT
RECORD Data Type 39

RECORD Data Type


,
RECORD member Data Type Declaration END RECORD
p. 37

LIKE table .*

Table Qualifier
p. 46

4GL Expression
Time Expression
p. 43

Character Expression
p. 42

Number Expression
p. 42.

Integer Expression
p. 41

4GL Boolean
Expression
p. 40

( 4GL Expression )

Named Value
variable

record .
,
array [ 3 Integer ]
Expression
p. 41

constant
Basics
4GL
Function Call Forms
function ( ) Reports
, SQL
SQLCA
4GL Debugger
Expression
p. 39 Variables
Keys
40 4GL Boolean Expression

4GL Boolean AND


Expression
OR
4GL Expression
p. 39

NOT Boolean Comparison

Function Call
p. 39

TRUE
FALSE

Boolean
Comparison
String Comparison

Set Membership Test


p. 41

NULL Test
p. 41

Relational Comparison

Relational
Comparison
4GL Expression = 4GL Expression
p. 39 p. 39
<
>
<=
>=
<>
!=

String Comparison
Character MATCHES criterion
Expression
p. 42 NOT LIKE ESCAPE "char"
NULL Test 41

MATCHES
Wildcard Effect
* Matches a string of zero or more characters.
? Matches any single character.
[] Matches any of the enclosed characters.
- Between characters in brackets means a range in the ASCII collating
sequence.
^ As the first character in the brackets, matches any character that is not listed.
\ Treats the next character as a literal.

LIKE
Wildcard Effect
% Matches a string of zero or more characters.
_ Matches any single character.
\ Treats the next character as a literal.

NULL Test
4GL Expression IS NULL
p. 39
NOT
blob variable

Set Membership ,
Test
4GL Expression IN ( 4GL Expression )
p. 39 p. 39
NOT

Case I: Pure integers


Integer Expression
Literal Integer +
p. 42
+ -
Function Call
- p. 39 *
Named Value /
Basics
p. 39 MOD
4GL
4GL Boolean
** Forms
Expression
p. 40 Reports
SQL
Case II: Differences between DATE values SQLCA
DATE Value DATE Value Debugger
p. 43
- p. 43 Variables
Keys
42 Literal Integer

Literal Integer
digit

+
-

Number
Expression

Literal Number +
+ Named Value -
p. 39
- *
Function Call / Integer
p. 39 Expression
MOD p. 41
4GL Boolean
Expression **
p. 40

Literal Number
digit

+ . -
- . digit E digit

e +

Character
Expression
" character "
Function Call CLIPPED USING "format-string"
p. 39

Named Value [ Integer ]


p. 39 Expression
p. 41
, Integer
Expression
p. 41
Time Expression 43

Time Expression
INTERVAL Value
p. 43

DATETIME Value
p. 43

DATE Value
p. 43

DATE Value
" Numeric Date "
p. 44
Function Call USING "format string"
p. 39
Named Value
p. 39
TODAY

DATETIME Value
" Numeric Date and Time "
p. 44
DATETIME Literal
p. 44
Function Call
p. 39
Named Value
p. 39

CURRENT DATETIME Qualifier


p. 44

EXTEND ( DATETIME )
Value
, DATETIME Qualifier
DATE Value p. 44

INTERVAL Value
" Numeric Time Interval "
p. 46
+ INTERVAL Literal Basics
p. 45 4GL
- Function Call Forms
p. 39
Reports
Named Value SQL
p. 39
SQLCA
Integer Expression UNITS keyword
p. 41 Debugger
Variables
Keys
44 Numeric Date

Numeric Date
mo yy

separator dd separator yyyy

DATETIME
Qualifier
YEAR

MONTH TO YEAR

DAY TO MONTH

HOUR TO DAY

MINUTE TO HOUR

SECOND TO MINUTE

FRACTION TO SECOND

TO FRACTION
(3)
( scale )

DATETIME Literal
DATETIME ( Numeric Date
and Time
) DATETIME Qualifier

Numeric Date and


Time
yyyy
-
mo
-
dd
space
hh
:
mi
:
ss
.
fffff
INTERVAL Qualifier 45

INTERVAL
Qualifier Case I: Time units smaller than MONTH
DAY
(precision) TO DAY
( 2)
HOUR
(precision) TO HOUR
( 2)
MINUTE
(precision) TO MINUTE
( 2)
SECOND
(precision) TO SECOND
( 2)
FRACTION TO FRACTION
( scale )
Case II: Time units greater than DAY ( 3)
YEAR
(y-precision) TO YEAR
( 4)
MONTH
(precision) TO MONTH
( 2)

INTERVAL Literal
INTERVAL ( Numeric Time Interval ) INTERVAL
Qualifier
p. 46

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
46 Numeric Time Interval

Numeric Time
Interval Case I: Time units smaller than MONTH
dd
space
-
hh
:
mi
:
ss
.
fffff

Case II: Time units greater than DAY


yyyy

- -
mo

,
Field Clause
field

table reference

screen record . *
screen array [ line ]
[1] THRU
Notation
FORMONLY

Table Qualifier

OL
owner.
database : "owner."
@server

THRU Notation
first THROUGH same.last

THRU
4GL Forms

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
48 DATABASE Section

Form
Specification
Syntax DATABASE SCREEN ATTRIBUTES
Section Section Section
TABLES p. 49 INSTRUCTIONS
Section Section
p. 49 p. 49

DATABASE
Section

DATABASE FORMONLY
DATABASE Section
database WITHOUT NULL INPUT
Database Reference

DATABASE Section
Database
Reference
database

database @server

OL "/ / server / database"


SE "/ pathname / database @server"
"/ / server / pathname / database"

SCREEN
Section

SCREEN { Screen Layout }


SIZE lines BY characters END

Screen Layout
[ field-tag ]

[ field-tag | field-tag ] character


TABLES Section 49

TABLES
Section

TABLES table

alias = Table Qualifier END


p. 46

ATTRIBUTES
Section

ATTRIBUTES field-tag = Field Description ;


END

Field Description
column

FORMONLY. field name TYPE LIKE table .

data-type NOT NULL

,
, Attributes
p. 50

INSTRUCTIONS
Section

INSTRUCTIONS SCREEN RECORD record ( Field List )


p. 50
array [ size ] END

DELIMITERS " opening-delimiter closing-delimiter "


Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
50 Field List

,
Field List
table . *
reference
last

first THROUGH table .


reference
THRU

Attributes
AUTONEXT
Attribute
AUTONEXT

COLOR Attribute
COLOR = display mode

WHERE Boolean
Expressions
for 4GL Forms
p. 51

Values for display mode consists of zero or one color and zero or more intensities:

Color Keywords Intensity Keywords


BLACK MAGENTA REVERSE
BLUE RED LEFT
CYAN WHITE BLINK
GREEN YELLOW UNDERLINE
Boolean Expressions for 4GL Forms 51

Boolean
Expressions for AND
4GL Forms
OR
4GL Expression
(Subset)
NOT p. 39 = 4GL Expression
(Subset)
< p. 39
field-tag >
<= field-tag
>=
<> TRUE
!= FALSE
IS NULL

NOT field-tag field-tag

NOT BETWEEN 4GL AND 4GL


Expression Expression
(Subset) (Subset)
p. 39 p. 39
,
IN ( 4GL Expression )
(Subset)
p. 39

field-tag

Character MATCHES " character "


Expression
p. 42
LIKE ESCAPE "char "

( Boolean Expression )
for 4GL Forms

COMMENTS
Attribute
COMMENTS = "message "

DEFAULT
Attribute Basics
4GL
DEFAULT = value
Forms
Reports
DISPLAY LIKE SQL
Attribute
SQLCA
DISPLAY LIKE column Debugger
table . Variables
Keys
52 DOWNSHIFT Attribute

DOWNSHIFT
Attribute
DOWNSHIFT

FORMAT
Attribute
FORMAT = "format-string"
For DATE data types, format-string consists of:

Special
Characters Meaning
mm 2-digit representation of the month
mmm 3-letter abbreviation of the month
dd 2-digit representation of the day of the month
ddd 3-letter abbreviation of the day of the week
yy 2-digit representation of the year, discarding
the leading digits
yyyy 4-digit representation of the year

All other characters are literals.


For DECIMAL, SMALLFLOAT, or FLOAT data types, format-string consists
of pound signs (#) to represent digits and a decimal point. If you are using NLS,
the period is a placeholder for the decimal separator and the comma is a
placeholder for the thousands separator.

INCLUDE Attribute
,
INCLUDE =( value )
TO value

NULL

INVISIBLE Attribute
INVISIBLE

NOENTRY Attribute
NOENTRY
PICTURE Attribute 53

PICTURE Attribute
PICTURE = "format-string"

A format-string can include these three special symbols:


Symbo
l Meaning
A Any letter
# Any digit
X Any character

PROGRAM
Attribute
PROGRAM = "command "

REQUIRED
Attribute
REQUIRED

REVERSE
Attribute
REVERSE

UPSHIFT Attribute
UPSHIFT

VALIDATE LIKE
Attribute
VALIDATE LIKE column

table .

VERIFY Attribute Basics


VERIFY 4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
54 WORDWRAP Attribute

WORDWRAP
Attribute
WORDWRAP

COMPRESS
NONCOMPRESS
Reports

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
56 REPORT

Report
Specification
Syntax
REPORT report ( ) FORMAT END REPORT
, Section
p. 58
argument ) DEFINE
Section

OUTPUT ORDER BY
Section Section
p. 56 p. 57

DEFINE
Section ,
DEFINE variable data Type
Data type Declaration
(Subset) p. 37

OUTPUT
Section

OUTPUT 1 REPORT TO "filename "


1 LEFT PRINTER

1 TOP PIPE "command "


1 BOTTOM MARGIN variable

1 RIGHT

1 PAGE LENGTH size

1 TOP OF PAGE "string "


ORDER BY Section 57

LEFT MARGIN size (default = 5 characters)


TOP
MARGIN size
(default = 3 lines)

PAGE LENGTH size


(default = 66 lines)

BOTTOM
MARGIN size
(default = 3 lines)

RIGHT MARGIN size (default = 132 lines)


(for default reports or PRINT WORDWRAP only)

ORDER BY
Section ,
ORDER BY argument

EXTERNAL ASC

DESC

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
58 FORMAT Section

FORMAT
Section

FORMAT EVERY ROW END REPORT

AFTER GROUP OF
Control Block

BEFORE GROUP OF
Control Block

1 FIRST PAGE HEADER


Control Block

1 PAGE HEADER
Control Block p. 59

1 ON EVERY ROW
Control Block p. 59

1 PAGE TRAILER
Control Block p. 59

1 ON LAST ROW
Control Block p. 59

Following is the execution sequence of report control blocks.

BEFORE GROUP OF a {1}


BEFORE GROUP OF b {2}
BEFORE GROUP OF c {3}
ON EVERY ROW {4}
AFTER GROUP OF c {3}
AFTER GROUP OF b {2}
AFTER GROUP OF a {1}

AFTER GROUP OF
Control Block
AFTER GROUP OF variable statement

BEFORE GROUP
OF
Control Block

BEFORE GROUP OF variable statement


FIRST PAGE HEADER Control Block 59

FIRST PAGE
HEADER
Control Block
FIRST PAGE HEADER statement

PAGE HEADER
Control Block
PAGE HEADER statement

ON EVERY ROW
Control Block
ON EVERY ROW statement

ON LAST ROW
Control Block
ON LAST ROW statement

PAGE TRAILER
Control Block
PAGE TRAILER statement

Report
Execution
Statements

NEED lines LINES

PAUSE

"string "
Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
60 PRINT

,
PRINT 4GL Expression
p. 39

COLUMN left offset


;
PAGENO
LINENO

BYTE variable

relative offset SPACE


SPACES
Aggregate Report Functions

Character
Expression
p. 42
WORDWRAP RIGHT MARGIN temporary

TEXT variable

FILE " filename"

Aggregate Report
Functions
PERCENT (*)
GROUP COUNT
4GL Boolean
AVG ( Number Expression ) WHERE Expression
p. 42 p. 40
SUM
INTERVAL Value
MAX ( p. 43 )
MIN 4GL Expression
( p. 39 )

SKIP TO TOP OF PAGE

integer LINE

LINES
SQL Statements

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
62 ALTER INDEX

The 4GL source compiler does not recognize SQL statements identified in this Guide
by the 6.0SE icon nor SQL statements containing a clause identified by the 6.0
SE
icon. To compile 4GL source code containing such statements, you must do the
following:
1. Store the 6.0 SQL statement as a character string.
2. Set up the statement for execution by means of the PREPARE statement (see p. 79).
3. Process the statement by means of the EXECUTE statement (see p. 75).

+
Index Name
ALTER INDEX p. 92 TO CLUSTER

NOT

,
+
Table Name ADD Clause
ALTER TABLE p. 92

Synonym DROP Clause


Name p. 63
p. 92
MODIFY Clause
p. 63

ADD CONSTRAINT
Clause p. 64

DROP CONSTRAINT
Clause p. 64
OL
MODIFY NEXT SIZE
Clause p. 64

LOCK MODE
Clause p. 64

ADD Clause
Add Column
ADD 6.0 Clause
p. 63
,
Add Column
( Clause )
p. 63
ALTER TABLE 63

Add Column
Clause new SQL
column Data Type
name p. 93 NOT ,
NULL Column-Level
6.0 Constraint Definition
p. 68
DEFAULT
Clause
p. 67
BEFORE column name

DROP Clause
DROP 6.0 column name
,
( column name )

MODIFY Clause
Modify Column
MODIFY 6.0 Clause

,
( Modify Column
Clause
)

Modify Column
Clause
column SQL
name Data Type
p. 93 NOT ,
NULL
6.0 Column-Level
Constraint Definition
p. 68
DEFAULT
Clause
p. 67 Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
64 BEGIN WORK

ADD
CONSTRAINT
Clause Constraint
ADD CONSTRAINT Definition
p. 68
6.0 ,
( Constraint
Definition
)
p. 68

DROP
CONSTRAINT
Clause
Constraint
DROP CONSTRAINT 6.0 Name
p. 92
,
Constraint
( Name )
p. 92

MODIFY
NEXT SIZE
Clause
MODIFY NEXT SIZE kbytes

LOCK MODE
Clause
LOCK MODE ( PAGE )
ROW

+
BEGIN WORK

Cursor
CLOSE Name
p. 92
CLOSE DATABASE 65

+
CLOSE
DATABASE

COMMIT WORK

SE
+
CREATE AUDIT FOR Table
Name
IN "pathname"
p. 92

Synonym
Name
p. 92

+
Database
CREATE Name
DATABASE p. 93
OL IN dbspace SE SE Log Clause
" databasename "
OL OL Log Clause

SE Log Clause
WITH LOG IN " pathname "

MODE ANSI

OL Log Clause
WITH LOG

BUFFERED

Basics
LOG MODE ANSI
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
66 CREATE INDEX

+
INDEX Index ON
CREATE Name Clause
p. 92 OL
UNIQUE CLUSTER
6.0
DISTINCT

FILLFACTOR percent

,
ON Clause
ON Table
Name
( column name )
p. 92
ASC
Synonym
Name DESC
p. 92

6.0
+
CREATE
PROCEDURE " filename "
FROM
Named Value
p. 103

+
Synonym
CREATE SYNONYM Name FOR Table Name
p. 92 p. 92
6.0
View Name
PUBLIC p. 92

PRIVATE
CREATE TABLE 67

, ,
Table Column Constraint
CREATE TABLE Name ( Definition , Definition )
p. 92 p. 67 p. 68
Storage
Option
p. 69

, ,
temp Temp Table Temp Table
+ TEMP table ( Column , Constraint )
TABLE name Definition Definition
p. 68

WITH NO LOG

Column Definition
SQL Data Type
column p. 93
6.0 Column-Level
NOT NULL
Constraint
DEFAULT Definition
Clause

Temp Table
Column Definition
column SQL Data Type
p. 93
6.0 Temp Table
NOT NULL
Column
DEFAULT Constraint
Clause p.68

DEFAULT Clause
Constant
DEFAULT Expression
p. 97

NULL Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
68 CREATE TABLE

Column-Level
Constraint
Definition
UNIQUE
+ +
Constraint
DISTINCT CONSTRAINT Name
6.0 p. 92

PRIMARY KEY

REFERENCES
Clause
p. 69

CHECK
Clause
p. 69

Temp-Table Column
Constraint
UNIQUE

+
DISTINCT

PRIMARY
KEY

CHECK
Clause
p. 69

Constraint ,
Definitiion
UNIQUE ( column )
+
+ Constraint
CONSTRAINT Name
DISTINCT p. 92
6.0

PRIMARY KEY ,
FOREIGN KEY ( column ) REFERENCES
Clause
p. 69
CHECK
Clause
p. 69
CREATE TABLE 69

Temp-Table
Constraint ,
Definition
UNIQUE ( column )
+
DISTINCT

PRIMARY KEY
CHECK
Clause
p. 69

REFERENCES
Clause
REFERENCES Table
Name
p. 92 6.0
,
OL
( column ) +
ON DELETE CASCADE

CHECK Clause
CHECK ( Condition
p. 91
)

Storage Option
OL

IN dbspace Extent Option


LOCK MODE
Clause
p. 70

SE IN "pathname "

Basics
Extent Option 4GL
Forms
Reports
EXTENT SIZE first kpages NEXT SIZE next kpages
SQL
SQLCA
Debugger
Variables
Keys
70 CREATE TRIGGER

LOCK MODE
Clause
LOCK MODE

PAGE

ROW

6.0
+
CREATE TRIGGER Trigger
Name

Table Action
INSERT ON Name Clause
p. 92 p. 71

Insert Action
REFERENCING Clause
Clause Referencing
p. 71 p. 72

Table Action
DELETE ON Name Clause
p. 92 71

Delete Action
REFERENCING Clause
Clause Referencing
p. 71 p. 72

UPDATE Table Action


Clause ON Name Clause
p. 71 p. 92 p. 71

Update Action
REFERENCING Clause
Clause Referencing
p. 72 p. 72

Trigger Name
Identifier
p. 100
owner.
CREATE TRIGGER 71

UPDATE Clause
UPDATE
,
OF column name

Action Clause
Triggered
BEFORE Action List
p. 72 Triggered Triggered
FOR EACH AFTER
Action List Action List
ROW p. 72 p. 72

FOR EACH Triggered


Action List
ROW p. 72
Triggered
AFTER Action List
p. 72
Triggered
AFTER Action List
p. 72

INSERT
REFERENCING
Clause
REFERENCING NEW correlation name

AS

DELETE
REFERENCING
Clause
REFERENCING OLD correlation name

AS

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
72 CREATE VIEW

UPDATE
REFERENCING
Clause
REFERENCING 1 OLD correlation
name
AS

1 NEW correlation
name
AS

ACTION Clause
Referencing
FOR EACH Triggered
ROW Action List
BEFORE Triggered Triggered
Action List AFTER Action List

,
Triggered Action ,
List
INSERT
( Statement )
p. 77
Condition
WHEN ( p. 91 ) DELETE
Statement
p. 73

UPDATE
Statement
p. 88

EXECUTE
PROCEDURE
p. 75

View SELECT
CREATE VIEW Name AS (Subset)
p. 92 , p. 82
WITH CHECK
column OPTION
( name )

+
Database
DATABASE Name
p. 93
EXCLUSIVE
DECLARE 73

INSERT
Cursor Statement
DECLARE Name CURSOR FOR +
p. 92 (Subset)
+ p. 77
WITH
HOLD
SELECT
Statement FOR
+
+ (Subset) UPDATE
p. 82
SCROLL ,
FOR
CURSOR

OF column
WITH
HOLD
SELECT
Statement
p. 82

Prepared
Statement
Name
p. 103

Table
DELETE FROM Name
p. 92
WHERE Condition
View p. 91
Name
p. 92
Cursor
Synonym CURRENT OF Name
Name p. 92
p. 92

SE
+
Table Name
DROP AUDIT FOR p. 92

Synonym
Name Basics
p. 92
4GL
Forms
Reports
+ Database SQL
DROP DATABASE Name SQLCA
p. 93
Debugger
" databasename " Variables
Keys
74 DROP INDEX

+ Index
DROP INDEX Name
p. 92

6.0
+
Procedure
DROP Name
PROCEDURE p. 92

+ Synonym
DROP SYNONYM Name
p. 92

+
Table
DROP TABLE Name
p. 92

Synonym
Name
p. 92

6.0
+
Trigger
DROP TRIGGER Name
p. 70

+
View
DROP VIEW Name
p. 92

Synonym
Name
p. 92
EXECUTE 75

+ Prepared
EXECUTE Statement
Name
p. 103 ,
USING Named Value
p. 103

6.0
+
EXECUTE Procedure
PROCEDURE Name ( )
p. 92 , ,
Argument INTO Named Value
p. 103

A procedure that returns no values must be executed by using PREPARE and


EXECUTE. A procedure that returns values must be handled by using PREPARE and
DECLARE, and then either a FOREACH loop or OPEN, FETCH, or CLOSE.

,
Cursor
FETCH Name INTO data variable
p. 92
+
NEXT
+
PREVIOUS

PRIOR
FIRST
LAST
CURRENT
RELATIVE

+ row position
Named Value
- p. 103
ABSOLUTE
Basics
4GL
Forms
+ Reports
Cursor
FLUSH Name SQL
p. 92
SQLCA
Debugger
Variables
Keys
76 FREE

+ TEXT or BYTE
FREE Named Value
p. 103

Prepared
Statement
Name
p. 103

Cursor
Name
p. 92

The 4GL compiler treats the name of the object to be freed in the order shown in the
diagram. In other words, the compiler looks first for a TEXT or BYTE variable having
the given name; if one exists, that is the object that is freed. If no TEXT or BYTE vari-
able having that name exists, the compiler then looks for a prepared statement or a
cursor having that name and frees that.
When a TEXT or BYTE variable has the same name as a prepared statement or cursor,
you cannot free resources allocated to the prepared statement or to the cursor.

Database-
GRANT + Level TO PUBLIC
Privileges
p. 81 ,
user
Table-
Level Table
Privileges ON Name TO PUBLIC
p. 77 p. 92

View
Name
p. 92

Synonym
6.0 Name
p. 92 ,
Procedure user
EXECUTE ON Name
p. 92

WITH GRANT OPTION + AS grantor


INSERT INTO 77

Table-Level
Privileges
ALL

PRIVILEGES

,
1 INSERT
1 DELETE
1 SELECT
+
,
( column
name
)
1 UPDATE
+
,
( column
name
)
1 6.0 REFERENCES
,
( column
name
)
1 INDEX

1 ALTER

Table VALUES Clause


INSERT INTO Name p. 78
p. 92 ,
View
Name ( column
name
)
p. 92 SELECT
Statement
Synonym (Subset)
Name p. 82
p. 92
6.0
Basics
4GL
Procedure
EXECUTE PROCEDURE Name ( ) Forms
p. 92 ,
Reports
Argument
p. 78 SQL
SQLCA
Debugger
Variables
Keys
78 INSERT INTO

Argument
SPL
Expression
p. 112
SPL parameter name =
SELECT
Statement
(singleton)
p. 82

,
VALUES Clause
VALUES ( Named Value )
p. 103

NULL

Constant
Expression
p. 97

Record
Reference .*
p. 104

Record
Reference . member
p. 104

Record
THRU Reference . member
p. 104
LOAD FROM 79

+
LOAD FROM " filename "
DELIMITER "delimiter"
Named Value
p. 103
Named Value
p. 103

Table
INSERT INTO Name
p. 92
,
Synonym
Name ( )
p. 92 column

View
Name
p. 92
Named Value
p. 103

+
Table
LOCK TABLE Name IN SHARE MODE
p. 92
EXCLUSIVE
Synonym
Name
p. 92

Cursor
OPEN Name
p. 92
,
USING Named Value
p. 103

Basics
Prepared
Statement Quoted 4GL
PREPARE Name FROM String
p. 103 p. 104 Forms
Reports
Named Value SQL
p. 103
SQLCA
Debugger
Variables
Keys
80 PUT

+
Cursor
PUT Name
p. 92
,
FROM Named Value
p. 103

SE
+
Table
RECOVER TABLE Name
p. 92

+
Table
RENAME COLUMN Name . old column TO new column
p. 92

+
RENAME TABLE old name TO new name

owner .

+
Table
REVOKE Table-Level ON Name FROM PUBLIC
Privileges
p. 81
p. 92 ,
View user
Name
p. 92

Synonym
Name
p. 92

Procedure
6.0 EXECUTE ON Name
p. 92

Database-Level
Privileges
p. 81
ROLLBACK WORK 81

Table-Level
Privileges
ALL

PRIVILEGES

INSERT

DELETE

SELECT

UPDATE

INDEX

ALTER
6.0 REFERENCES

Database-Level
Privileges
CONNECT

RESOURCE

DBA

ROLLBACK WORK

SE
+
Database
ROLLFORWARD Name
DATABASE p. 93

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
82 SELECT

UNION

UNION ALL
Select FROM
SELECT Clause Clause
p. 83
INTO
Clause
p. 83

WHERE GROUP BY HAVING


Clause Clause Clause
p. 84 p. 85 p. 85

+
ORDER BY INTO TEMP
Clause Clause
p. 86 p. 86

,
SELECT Clause
Select
Item
p. 83
ALL
DISTINCT
+
UNIQUE
SELECT 83

Select Item
SQL Expression
p. 96
display label
+
AS

*
Table
Name .
p. 92

View
Name .
p. 92

Synonym
Name .
p. 92

,
INTO Clause
INTO Named Value
p. 103

FROM Clause Table


FROM Name
p. 92 Additional
table , Tables
View alias p. 84
Name +
p. 92
AS
Synonym
Name
p. 92

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
84 SELECT

,
Additional Tables
Table
Name
p. 92
table alias
View
+ Name +
p. 92
AS
Synonym
Name
p. 92
Table
OUTER Name
p. 92
table alias
View
Name
p. 92 AS

Synonym
Name
p. 92

Table
OUTER ( Name )
p. 92
table , Additional
View alias Tables
Name
p. 92 AS

Synonym
Name
p. 92

AND
WHERE Clause
Condition
WHERE p. 91

Join
p. 85
SELECT 85

Join Relational
column name Operator column name
p. 104
Table Table
Name . Name .
p. 92 p. 92

table alias . table alias .


View View
Name . Name .
p. 92 p. 92

Synonym Synonym
Name . Name .
p. 92 p. 92

,
GROUP BY Clause
GROUP BY column name
Table
Name .
p. 92

table alias .
View
Name .
p. 92

Synonym
Name .
p. 92

+ select number

HAVING Clause
HAVING Condition
p. 91

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
86 SET CONSTRAINTS

,
ORDER BY Clause
ORDER BY column name
Table
Name . ASC
p. 92 DESC

table alias .

View
Name .
p. 92

Synonym
Name .
p. 92

select number

display label

rowid

INTO TEMP Clause


INTO TEMP temp table name

WITH NO LOG

6.0
OL
+
SET ALL
CONSTRAINTS IMMEDIATE

, DEFERRED

Constraint Name
p. 92

6.0
+
SET DEBUG FILE TO " filename "
Named Value WITH APPEND
p. 103
character expression
SET EXPLAIN 87

+
SET EXPLAIN OFF

ON

OL
+
SET ISOLATION TO DIRTY READ

COMMITTED READ

CURSOR STABILITY

REPEATABLE READ

+
SET LOCK MODE TO WAIT
OL
seconds

NOT WAIT

OL
+
SET LOG

BUFFERED

6.0
+
SET HIGH
OPTIMIZATION
LOW
Basics
4GL
Forms
SE
Reports
+
Database SQL
START DATABASE Name WITH LOG IN "pathname"
p. 93 SQLCA
MODE ANSI Debugger
Variables
Keys
88 UNLOAD

+
SELECT
UNLOAD TO " filename " Statement
p. 82
DELIMITER " delimiter "
Named Value
p. 103
Named Value
p. 103

+ Table
UNLOCK TABLE Name
p. 92

Synonym
Name
p. 92

Table SET Clause


UPDATE Name SET p. 89
p. 92
WHERE Condition
View p. 91
Name
p. 92

Synonym Cursor
Name CURRENT OF Name
p. 92 p.92
UPDATE 89

,
SET Clause
column name = SQL Expression
(Subset)
p. 96

SELECT
Statement
(Subset)
p. 82

Record
Reference . member
p. 104

, ,
column
( name ) = ( SQL Expression )
(Subset)
p. 96
*
SELECT
Table Statement
Name .* ( (Subset) )
p. 92 p. 82

View
Name .* Referenced
Values
p. 92

Synonym Referenced
Name .* Values
p. 92

Referenced Values Record


Reference .*
p. 104

Record
Reference . member
p. 104

Record Record
Reference . member THRU Reference . member
p. 104 p. 104
Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
90 UPDATE STATISTICS

+
UPDATE
STATISTICS

6.0 FOR PROCEDURE

Procedure
Name
p. 92

6.0 6.0
FOR
LOW TABLE Table DROP DISTRIBUTIONS
Specification
6.0
MEDIUM
FOR
TABLE Table RESOLUTION conf
Specification percent

HIGH
FOR
TABLE Table RESOLUTION percent
Specification

Table Specification
Table Name
p. 92
6.0 ,
Synonym Name ( column )
p. 92

WHENEVER NOT FOUND CONTINUE

SQLERROR GOTO label

+ GO TO :label
+
ERROR

STOP
ANY
CALL function name
WARNING
6.0

SQLWARNING
Condition 91

SQL
Segments AND

OR
Condition
Comparison
Condition
NOT
IN
Subquery
p. 92

EXISTS
Subquery
p. 92

ALL/ANY/SOME
Subquery
p. 92

Comparison
Condition
SQL Expression Relational SQL Expression
p. 96 Operator p. 96
p. 104

SQL Expression BETWEEN SQL Expression


p. 96 AND SQL Expression
p. 96
p. 96
NOT
,
SQL Expression Constant
+ p. 96 IN ( Expression )
p. 97
NOT

Column
Expression IS NULL
p. 96
NOT

Column Quoted
Expression LIKE String ESCAPE "character"
p. 96 p. 104
+ Basics
NOT
MATCHES Named
Value 4GL
p. 103 Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
92 IN Subquery

IN Subquery
SQL Expression SELECT
p. 96 IN ( (Subset) )
p. 82
NOT

EXISTS Subquery
SELECT
EXISTS ( (Subset) )
p. 82
NOT

ALL/ANY/SOME
Subquery Relational SELECT
SQL Expression ( )
p. 96 Operator (Subset)
p. 104 p. 82
ALL
ANY
SOME

Constraint Name
Index Name
Procedure Name
Synonym Name
Table Name
View Name
Identifier
p. 100
OL ' owner.'
database :
@dbservername

Cursor Name
Identifier
p. 100
Database Name 93

Database Name
Identifier
p. 100

OL @dbservername

OL "//dbservername/dbname"

Named Value
p. 103
SE

"/pathname/dbname@dbservername"

"//dbservername/pathname/dbname"

For SE engines, database identifiers can have up to ten characters in UNIX.


When the identifier for a database is also the name of a 4GL variable, the compiler uses
the variable. To override this compiler action, quote the database identifier.

SQL Data Type


Character
Data Type
p. 94

Number
Data Type
p. 94

Time
Data Type
p. 95

Large Object
Data Type
p. 95 Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
94 Character Data Type

Character Data
Type
CHAR

CHARACTER ( size )
6.0
NLS (1 )
+

NCHAR
OL
+ VARCHAR ( maximum )

6.0 , reserve
NLS ,0
NVARCHAR

Number
Data Type
INTEGER

INT

+ SERIAL

(1 )
(start)
SMALLINT

FLOAT

DOUBLE PRECISION ( float precision )


+ SMALLFLOAT

REAL

DECIMAL

DEC ( precision )
NUMERIC 16 , scale

+ MONEY

( precision )
16 ,2
, scale
Time Data Type 95

Time
Data Type
+ DATE

+ DATETIME DATETIME Field Qualifier

+ INTERVAL INTERVAL Field Qualifier


p. 101

Large Object
Data Type
OL
TEXT
+
BYTE IN TABLE

blobspace

DATETIME
Field Qualifier
YEAR

MONTH TO YEAR

DAY TO MONTH

HOUR TO DAY

MINUTE TO HOUR

SECOND TO MINUTE

FRACTION TO SECOND

TO FRACTION

(3 )
(digit)
Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
96 SQL Expression

+
-
*
/
6.0
||

SQL Expression Column


Expression
p. 96
-
+ Constant
Expression
p. 97

Function
Expression
p. 98

Aggregate
Expression
p. 100

Named Value
p. 103

( SQL Expression )

n UNITS datetime unit

Column
Expression
column name
Table
. +
@ Name
p. 92 + [first, last ]
table alias . ROWID

View
Name .
p. 92

Synonym
Name .
p. 92

When you refer to a column whose name is identical to that of a variable, you
must prefix the column name with an @ symbol; otherwise the 4GL compiler
treats it as a variable.
Constant Expression 97

Constant
Expression
Quoted String
p. 104

USER

Literal Number
+ p. 103

TODAY

CURRENT
DATETIME Field
Qualifier
p. 95

Literal DATETIME
p. 101

Literal INTERVAL
p. 102
OL
SITENAME
6.0
DBSERVERNAME

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
98 Function Expression

Function
Expression
+ DAY ( date expression )
MONTH datetime expression
WEEKDAY
YEAR

DATE ( nondate expression )


EXTEND ( date expression )
DATETIME
datetime expression , Field Qualifier
p. 95

month day year


MDY ( integer , integer , integer )
expression expression expression

LENGTH ( Quoted String )


p. 104

variable name

column name

Table Name .
p. 92

HEX ( integer expression )

Algebraic Functions
p.99
6.0
Procedure SPL Expression
Name ( p. 112 )
p. 92

DBINFO Function
p. 99

Exponential and Logarithmic Functions


p. 99

Trigonometric Functions
p. 100
Algebraic Functions 99

Algebraic
Functions
SQL
ROUND ( Expression )
p. 96
, rounding factor
,0
SQL
TRUNC ( Expression )
p. 96
, truncating factor
6.0
,0

ABS ( numeric expression )


MOD ( dividend, divisor )
POW ( base, exponent )

ROOT ( radicand )
, index
,2
SQRT ( integer expression )

DBINFO Function
DBINFO ( OL 'DBSPACE' , tblspace num )
expression
'sqlca.sqlerrd1'
'sqlca.sqlerrd2'

Exponential
and Logarithmic
Functions
EXP ( float expression ) Basics
4GL
LOGN ( float expression ) Forms
LOG10 ( float expression ) Reports
SQL
SQLCA
Debugger
Variables
Keys
100 Trigonometric Functions

Trigonometric
Functions
COS ( radian expression )
SIN

TAN

ASIN ( numeric expression )


ACOS
ATAN

ATAN2 ( y, x )

Aggregate
Expression
COUNT (*)

AVG ( column
name
)
Table .
MAX DISTINCT Name
MIN p. 92
UNIQUE
SUM
COUNT ( DISTINCT

UNIQUE

AVG ( Expression
(Subset)
)
p. 96
MAX ALL
MIN
SUM

Identifier
letter

17 letter

digit
underscore
INTERVAL Field Qualifier 101

INTERVAL
Field Qualifier
YEAR

(y-precision) TO YEAR
(4)
MONTH

(precision) TO MONTH
(2)
DAY

(precision) TO DAY
(2)
HOUR

(precision) TO HOUR
(2)
MINUTE

(precision) TO MINUTE
(2)
SECOND

(precision) TO SECOND
(2)
FRACTION TO FRACTION

(f-precision)
(3)

Literal DATETIME Numeric DATETIME


DATETIME ( Datetime ) Field Qualifier
p. 102 p. 95

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
102 Numeric Datetime

Numeric Datetime
yyyy

-
mo

-
dd

space

hh

:
mi

:
ss

.
f

Literal INTERVAL
INTERVAL
INTERVAL ( Numeric Interval ) Field Qualifier
p. 101

Numeric Interval
yyyy
-
mo

dd
space
hh
:
mi
:
ss
.
f
Literal Number 103

Literal Number
digit

+ .
-
. digit E digit

+
-

Named Value
variable

record .
,
3 array [ integer expression ]

Function Call
function ( )
,
integer expression

Prepared
Statement Name
Identifier
p. 100

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
104 Quoted String

Quoted String
+ " "

character

""
' '

character

' '

Record Reference
program record

record .
,
3 array [ integer expression ]

Relational
Operator
<

<=
>
=
>=
<>

!=
105

Stored It is important to recognize that Stored Procedure Language (SPL) statements are
not part of 4GL. This means that you cannot include these statements within a 4GL
Procedure program. Doing so causes compile errors.
Language
To create a stored procedure from a 4GL program, do the following:
Statements
1. Put the text of the CREATE PROCEDURE statement in a file.
2. Use a PREPARE statement to prepare a CREATE PROCEDURE FROM statement
that refers to the text file created in Step 1.
3. Use an EXECUTE statement to execute the prepared statement, which then
compiles the stored procedure.
Refer to the Informix Guide to SQL: Reference, Version 6.0 for a full description of the
CREATE PROCEDURE statement.

You may explicitly invoke stored procedures from within your 4GL program by
preparing and executing the following SQL statements:
• CREATE PROCEDURE FROM
• DROP PROCEDURE
• EXECUTE PROCEDURE
• GRANT
• INSERT INTO
• REVOKE
• SET DEBUG FILE TO
• UPDATE STATISTICS
Refer to the Informix Guide to SQL: Reference, Version 6.0 for a description of
working with dynamic SQL.
Also, you may implicitly invoke a stored procedure through a reference to that
procedure within the context of an SQL expression. For example, the reference to
avg_price( ) in the following SELECT statement implicitly invokes the stored pro-
cedure having the name avg_price:

select
manu_code, unit_price,
(avg_price(1) - unit_price) variance
from stock Basics
where stock_num = 1 4GL
Forms
Such implicit references to stored procedures do not require the Reports
statement to be prepared. SQL
SQLCA
Debugger
Variables
Keys
106 CALL

Procedure
CALL Name ( ) ;
p. 92
, ,
procedure
Argument RETURNING variable

Argument SPL
Expression
p. 112
parameter name =
SELECT
Statement
(Subset)
p. 82

CONTINUE FOR ;
WHILE

FOREACH

,
variable SQL Data Type Default
DEFINE GLOBAL
name (Subset) DEFAULT
Value
;
p. 93 p. 107
OL REFERENCES BYTE DEFAULT
NULL

TEXT
,
variable SQL Data Type
name (Subset)
p. 93

OL REFERENCES BYTE

TEXT

Table Name
LIKE p. 92 . column
Synonym
Name
p. 92

View Name
p. 92

PROCEDURE
EXIT 107

Default Value
Constant
Expression
p. 97

NULL

EXIT FOR ;
WHILE

FOREACH

,
variable Statement
FOR name IN ( left
expression
TO right
expression
) Block END
p. 108 FOR

;
increment
STEP expression

,
expression

= left
expression
TO right
expression

increment
STEP expression

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
108 FOR

Statement
Block

CALL
DEFINE ON Statement
Statement EXCEPTION p. 106
p. 106 Statement
p. 111 CONTINUE
Statement
p. 106
EXECUTE PROCEDURE
Statement
see SQL:S, Version 6.0
EXIT
Statement
p. 107
FOR
Statement
p. 107
FOREACH
Statement
p. 109
IF
Statement
p. 109
LET
Statement
p. 111
RAISE EXCEPTION
Statement
p. 111
RETURN
Statement
p. 111
SYSTEM
Statement
p. 111
TRACE
Statement
p. 112
WHILE
Statement
p. 112

SQL Statement

BEGIN Statement END


Block
FOREACH 109

SELECT...INTO Statement END


FOREACH Statement Block FOREACH
p. 83 p. 108
cursor
WITH HOLD ;
FOR
name
WITH HOLD

EXECUTE Procedure
PROCEDURE Name ( )
p. 92 ,
variable
INTO name

,
SPL
Expression
(Subset)
variable p. 112
name =

IF Condition THEN END IF


p. 91
IF Statement ;
List
p. 110

Condition IF Statement IF Statement


ELIF THEN List ELSE List
p. 91
p. 110 p. 110

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
110 IF

IF Statement List
Statement
BEGIN Block END
p. 108

CALL
Statement
p. 106

CONTINUE
Statement
p. 106

EXIT
Statement
p. 107

FOR
Statement
p. 107

FOREACH
Statement
p. 109

IF
Statement
p. 109

LET
Statement
p. 111

RAISE EXCEPTION
Statement
p. 111

RETURN
Statement
p. 111

SYSTEM
Statement
p. 111

TRACE
Statement
p. 112

WHILE
Statement
p. 112

SQL Statement
LET 111

,
, ,
variable Procedure SPL
LET name = Name ( Expression ) ;
p. 92 p. 112
called
variable =

,
SPL
Expression
p. 112

Statement
ON EXCEPTION Block END EXCEPTION
p. 108
, ;
error
IN ( number )

SQL WITH RESUME


SET error
variable ISAM
, error
variable error
, data
variable

RAISE
EXCEPTION SQL error ;
, ISAM error
, error text

RETURN ;
,
SPL
Expression
p. 112
WITH RESUME Basics
4GL
Forms
SYSTEM " character expression " ;
Reports
character variable SQL
SQLCA
Debugger
Variables
Keys
112 TRACE

TRACE ON ;

OFF

PROCEDURE

SPL
Expression

Condition Statement
WHILE Block END WHILE
p. 91
p. 108
;

SPL Expression
SQL Expression
p. 96
||
procedure +
variable
name -
*
( SPL )
/ Expression

,
Procedure
Name ( SPL )
p. 92 Expression
called =
variable
SQLCA Record

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
114

DEFINE SQLCA RECORD


SQLCODE INTEGER,
SQLERRM CHAR(71),
SQLERRP CHAR(8),
SQLERRD ARRAY [6] OF INTEGER,
SQLAWARN CHAR (8)
END RECORD

Summary of fields:

Result Code Details of Statement Execution Special Conditions


STATUS SQLCA.SQLERRD[1] SQLCA.SQLAWARN[1]
or through through
SQLCA.SQLCODE SQLCA.SQLERRD[6] SQLCA.SQLAWARN[8]

SQLCODE indicates the result of executing an SQL statement.


It is set as follows:
• To zero for a successful execution of most statements.
• To NOTFOUND (defined as 100) for a successfully executed query that
returns zero rows or for a FETCH that seeks beyond the end of an active
set. (However, in an ANSI-compliant database, when an INSERT INTO/
SELECT statement or a DELETE, UPDATE, or SELECT INTO TEMP state-
ment fails to access any rows, the value of SQLCA.SQLCODE is set to
NOTFOUND rather than 0.)
• To a negative value for an unsuccessful execution.
INFORMIX-4GL sets the global variable STATUS equal to SQLCODE after
each SQL statement. However, any subsequent 4GL statement can reset
STATUS.
SQLERRM contains parameters for the error message.
SQLERRP is reserved for future use.
SQLERRD is an array of six integers:
SQLERRD[1] is the estimated number of rows returned.
SQLERRD[2] is the SERIAL value returned or an error code.
SQLERRD[3] is the number of rows processed.
SQLERRD[4] is a weighted sum of disk accesses and total rows
processed, the estimated CPU cost of the query.
SQLERRD[5] is the offset of error into the SQL statement.
SQLERRD[6] is the rowid of the last row processed.
115

SQLAWARN is a character string of length eight whose individual characters signal


various warning conditions (as opposed to errors) following the exe-
cution of an SQL statement. The characters are blank if no problems
or exceptional conditions are detected.
SQLAWARN[1] is set to W if one or more of the other warning
characters has been set to W. If SQLAWARN[1] is
blank, you do not have to check the remaining
warning characters.
SQLAWARN[2] is set to W if one or more data items were truncated to
fit into a character variable or if a DATABASE state-
ment selected a database with transactions.
SQLAWARN[3] is set to W if an aggregate function (SUM, AVG, MAX,
or MIN) encountered a null value in its evaluation or
if a DATABASE statement selected an ANSI-compli-
ant database.
SQLAWARN[4] is set to W if a DATABASE statement selected an
INFORMIX-OnLine Dynamic Server<Default ¶ Fo>
database or when the number of items in the select-
list of a SELECT clause is not the same as the number
of program variables in the INTO clause. In the latter
case, the number of values INFORMIX-4GL returns is
the smaller of these two numbers.
SQLAWARN[5] is set to W if float-to-decimal conversion is used.
SQLAWARN[6] is set to W when your program executes an Informix
extension to ANSI-compliant standard syntax and
the DBANSIWARN environment variable is set or the
-ansi option is specified.
SQLAWARN[7] is reserved for future use.
SQLAWARN[8] is reserved for future use.

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
116
Interactive
Debugger
Commands

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
118

The following table lists the Debugger commands, options, and accelerators.

Command Option Shortest Form


? ?
/ /
ALIAS al
APPLICATION ap
DEVICE ap d
BREAK b
IF b if
CALL ca
CLEANUP cl
ALL cl a
CONTINUE co
DATABASE da
DISABLE di
ALL di all
DUMP du
ALL du a
GLOBALS du g
ENABLE en
ALL en all
EXIT ex
FUNCTIONS f
GROW g
SOURCE gs
COMMAND gc
HELP h
ALL ha
LET le
LIST li
BREAK li b
TRACE li t
NOBREAK nob
ALL nob all
NOTRACE not
ALL not all
PRINT p
READ re
RUN ru
STEP s
INTO si
NOBREAK sn
TIME DELAY ti
SOURCE ti s
COMMAND ti c
Command-Line Syntax 119

Command Option Shortest Form


TRACE tr
FUNCTIONS tr functions
TURN tu
ON tu on
OFF tu of
USE us
VARIABLE va
ALL va all
GLOBALS va globals
VIEW vi
LINE vi l
WHERE wh
WRITE wr
ALIAS wr a
BREAK wr b
TRACE wr t

After setting a breakpoint (or tracepoint), the Output text region displays:

reference checkpoint line


number type function number module

(2) break show_menu:91 [customer.4gl]


scope function: show_menu

checkpoint scope

Command- To: Type:


Line Syntax Escape ! command
Interrupt CONTROL-D or Del key
Redraw CONTROL-R
Screen CONTROL-P
Toggle CONTROL-T
Search for characters / pattern Basics
? pattern 4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
120 ALIAS

/ pattern

? pattern

ALIAS alias name = command


AL

Command
List
p. 127

APPLICATION break line


AP
DEVICE

BREAK Checkpoint - count IF boolean expression


B Initializaton
p. 126
Checkpoint Command
Target List
p. 127 p. 127

These built-in operators can be used in a boolean expression:

CURRENT ENTEND( ) TODAY


DATE( ) INTERVAL( ) UNITS
DATETIME( ) MDY( ) WEEKDAY( )
DAY( ) MONTH( ) YEAR( )

CALL function name ( )


CA
,
argument
CLEANUP 121

CLEANUP
CL
ALL

CONTINUE
CO

DATABASE database
DA

To select a remote database, use one of the following formats:

Remote Database Engine Format of database name


INFORMIX-OnLine database@servername
Dynamic Server or
//servername/database

INFORMIX-SE //servername/path/database

DISABLE Checkpoint
DI Identification
p. 126

DUMP Scope
DU List
p. 128
Output
Redirection
p. 127

Checkpoint
ENABLE Identification Basics
EN p. 126
4GL
Forms
Reports
EXIT SQL
EX SQLCA
Debugger
Variables
Keys
122 FUNCTIONS

FUNCTIONS
F
pattern
Output
Redirection
p. 127

A pattern is a string of no more than 50 characters and blanks or up to


80 characters if enclosed in quotation marks.
You can use the following wildcard characters within the pattern:

Pattern Matches

? any single character

* zero or more characters


[characters] one or more unseparated characters
[character-character] characters within the range
in ASCII collating sequence

GROW integer
G
SOURCE –
COMMAND

HELP
H
command

ALL

LET Scope variable = 4GL expression


LE Qualification
p. 128

LIST
LI

BREAK

TRACE
NOBREAK 123

NOBREAK Checkpoint
NOB Identification
p. 126

NOTRACE Checkpoint
NOT Identification
p. 126

PRINT 4GL expression


P
OL
Output
PROGRAM = "program" Redirection
p. 127

These built-in operators can be used within a 4GL expression:

CURRENT ENTEND( ) TODAY


DATE( ) INTERVAL( ) UNITS
DATETIME( ) MDY( ) WEEKDAY( )
DAY( ) MONTH( ) YEAR( )

READ filename
RE
.4db

RUN
RU

argument
To pass arguments to the p-code runner, include them on the
Debugger command line.

Basics
STEP 4GL
S Forms
number INTO NOBREAK
Reports
SQL
SQLCA
Debugger
Variables
Keys
124 TIME DELAY

TIME DELAY integer


TI
SOURCE

COMMAND

Checkpoint
TRACE Initialization FUNCTIONS
TR p. 126
Checkpoint Command Output
Target List Redirection
p. 127 p. 127 p. 127

TURN AUTOTOGGLE
TU
ON DISPLAYSTOPS
OFF EXITSOURCE
PRINTDELAY
SOURCETRACE

USE
US ,
=
pathname

VARIABLE Scope
VA List
p. 128
Output
Redirection
p. 127
Scope variable
Qualification
p. 128
VIEW 125

VIEW function
VI
filename

number

LINE

WHERE
WH
Output
Redirection
p. 127

WRITE
WR
filename
BREAK
>>
TRACE
ALIAS

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
126 Checkpoint Identification

4GL
Interactive
Debugger
Command
Segments

Checkpoint
Identification
reference number

reference name

function name

ALL

Checkpoint
Initialization

* ( function name ) "reference name"

A reference name must:


• Be unique among other checkpoint names.
• Begin with an alphabetic character.
• Contain only letters, numbers, or the underscore ( _ ) character.
Checkpoint Target 127

Checkpoint Target
statement line

module .

Scope variable
Qualification
p. 128

function name

Type Valid Entities Triggered When


statement executable statements within 4GL Execution completes previous
functions statement.
variable †active variables Variable is assigned a different value.
function 4GL functions (including MAIN), 4GL Function is called.
reports, ESQL/C functions, C functions

†You cannot set a checkpoint on an entire array or record structure.

Command List

;
{ command }

Output Redirection
>> filename

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
128 Scope List

Scope List

GLOBALS
ALL

Scope Qualification

GLOBAL .
MODULE. module
FUNCTION. function
Environment
Variables

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
130 Environment Variables

INFORMIX INFORMIX-4GL Reference


Environment Variable Restrictions Page
DBANSIWARN D-8
DBDATE D-9
DBDELIMITER D-11
DBEDIT D-11
DBFORMAT D-14
DBLANG D-18
DBMONEY D-21
DBPATH D-23
DBPRINT D-26
DBREMOTECMD OnLine only D-27
DBSPACETEMP OnLine only D-28
DBTEMP SE only D-29
DBUPSPACE D-29
ENVIGNORE D-30
INFORMIXCONRETRY D-30
INFORMIXCONTIME D-31
INFORMIXDIR D-32
INFORMIXSERVER D-33
INFORMIXSHMBASE OnLine only D-33
INFORMIXSTACKSIZE OnLine only D-34
INFORMIXTERM D-34
ONCONFIG OnLine only D-36
PSORT_DBTEMP OnLine only D-36
PSORT_NPROCS OnLine only D-37
SQLEXEC D-38
SQLRM SQL APIs only D-38
SQLRMDIR SQL APIs only D-39
Environment Variables 131

INFORMIX-4GL Reference
NLS Environment Variable Page
COLLCHAR E-18
DBAPICODE E-23
DBNLS E-16
LANG E-25
LC_COLLATE E-27
LC_CTYPE E-29
LC_MONETARY E-31
LC_NUMERIC E-35

INFORMIX-4GL Reference
UNIX Environment Variable Page
PATH D-40
TERM D-41
TERMCAP D-41
TERMINFO D-42

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
132 Environment Variables
Default Key
Assignments

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
134 Default Key Assignments

Logical command keys at runtime and their default assignments:

Key
Name Purpose of Key Default Keystroke
Accept Selects the current menu option in a MENU Escape
statement; terminates input during CONSTRUCT,
INPUT and INPUT ARRAY; terminates DISPLAY
ARRAY.
Interrupt Represents the external interrupt signal; available CONTROL-C
when interrupts are deferred with the DEFER
statement.
Insert Requests insertion of a new line during INPUT F1
ARRAY, starting execution of a BEFORE INSERT block.
Delete Requests deletion of the current line during INPUT F2
ARRAY, starting execution of a BEFORE DELETE
block.
Next Causes scrolling to the next page (group of lines) F3
during DISPLAY ARRAY and INPUT ARRAY.
Previous Causes scrolling to the previous page (group of lines) F4
during DISPLAY ARRAY and INPUT ARRAY.
Help Starts the display of the specified HELP message from CONTROL-W
the current help file.
Quit Terminates the program unless DEFER QUIT is CONTROL-\
specified.

Effect of special keys on interactive 4GL statements and within 4GL menus:

Use in CONSTRUCT, INPUT, and


Key Name INPUT ARRAY Use in MENU
CONTROL-A Switches between overtype and insert None.
modes.
CONTROL-D Deletes from the cursor to the end of the None.
field.
CONTROL-H During text entry, moves the cursor left one Moves highlight to next
(backspace) position (nondestructive backspace). option left.
CONTROL-I Cursor moves to next field; except in a None.
or TAB WORDWRAP field, inserts a tab or skips to a
tab depending on mode.
CONTROL-J Cursor moves to next field; except in a Moves the highlight to
(Linefeed) WORDWRAP field, inserts a newline or the next option right.
moves down one line depending on mode.
CONTROL-L During text entry, moves the cursor right Moves the highlight to
one position. the next option right.
Default Key Assignments 135

Use in CONSTRUCT, INPUT, and


Key Name INPUT ARRAY Use in MENU
CONTROL-M Completes entry of the current field. Cursor Accepts the option that
or RETURN moves to next field if any; else same as is currently highlighted.
Accept.
CONTROL-N Cursor moves to beginning of current field. None.
CONTROL-R Causes the screen to be redrawn. Causes the screen to be
redrawn.
CONTROL-X Deletes the character under the cursor. None.
Left Arrow Same as Backspace. Same as Backspace.
Right Arrow Same as CONTROL-L. Same as CONTROL-L.
Up Arrow Moves to previous field; except in Moves the highlight to
a WORDWRAP field moves up one line in the next option left.
field and in an INPUT ARRAY moves to the
corresponding field in the previous row.
Down Arrow Moves to next field; except in a WORDWRAP Moves the highlight to
field moves down one line in field and in an the next option right.
INPUT ARRAY moves to the corresponding
field in the next row.

Default function key assignments in the Debugger:

Default Key Equivalent Command


F1 HELP
F2 STEP
F3 STEP INTO
F4 CONTINUE
F5 RUN
F6 LIST BREAK TRACE
F7 LIST
F8 DUMP
F9 EXIT

Basics
4GL
Forms
Reports
SQL
SQLCA
Debugger
Variables
Keys
136 Default Key Assignments

You might also like