Informix 4GL Quick Syntax, Version 6.0 - PACS Support

534 downloads 446 Views 733KB Size Report
The following people contributed to this version of INFORMIX-4GL Quick Syntax: ... Syntax diagrams describe the format of SQL, SPL, and 4GL statements and ...
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

Basics

6

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 4GL Statement Segments 37

21

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

Environment Variables

129

Default Key Assignments

133

126

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: 6.0 servers:

Informix Guide to SQL: Reference Informix Guide to SQL: Syntax, Version 6.0

Chapter 6 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 Debugger

Chapter 9

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 Conventions

Syntax diagrams describe the format of SQL, SPL, and 4GL statements and Debugger 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

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 counterclockwise from the right, the path always approaches elements from the left and continues 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

Scope List Named Value

Scope List p. 148 Named Value

A word in italics represents a value that you must supply. The nature of the value is explained fully in the appropriate reference manual. A reference in a box represents a subdiagram on the same page (if no page number is supplied) or on a specified page. Imagine that the subdiagram is spliced into the diagram at this point. (A synonym for “subdiagram” is “segment.”) If the term “(subset)” appears in the box below the name of the segment being referenced, you should refer to the appropriate reference 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 following codes are used: 6.0 SE

Path requires the statement to be prepared (by using PREPARE).

SE

Path is valid only for INFORMIX-SE.

OL

Path is valid only for INFORMIX-OnLine Dynamic Server.

+ NLS

Path is an Informix extension to ANSI standard SQL. Path is valid only if you are using NLS.

7

8

Syntax Conventions

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.

ALL

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 complete. 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 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.

variable

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

Reference Box

Loop

Path

,

,

variable name

INITIALIZE

Subdiagram Title

record

Column List

LIKE

.*

TO NULL

Optional Branch

Column List

Keyword

Required Element table .

OL

owner .

:

database

Icon

@ server

Elements of a syntax diagram

Terminator

Punctuation

Variable

column

* Segment Indicator

Basics

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

10

Data Types

Data Types

Data Type

Kind of Values Stored

ARRAY OF type BYTE CHAR CHARACTER DATE DATETIME DEC DECIMAL DOUBLE PRECISION FLOAT INT INTEGER INTERVAL MONEY NUMERIC REAL RECORD ➁SERIAL SMALLFLOAT SMALLINT ➀TEXT ➀VARCHAR

Arrays of values of any other single data type. Any kind of binary data. Character strings of up to 32,767 ASCII characters. (This keyword is a synonym for CHAR.) Points in time, specified as calendar dates. Points in time, specified as calendar dates and time-of-day. (This keyword is a synonym for DECIMAL.) Fixed point numbers, of a specified scale and precision. (These keywords are a synonym for FLOAT.) Floating-point numbers, of up to 32-digit precision. (This keyword is a synonym for INTEGER.) Whole numbers, from -2,147,483,647 to +2,147,483,647. Spans of time in years and months, or else in smaller time units. Currency amounts, with definable scale and precision. (This keyword is a synonym for DECIMAL.) (This keyword is a synonym for SMALLFLOAT.) Ordered sets of values, of any combination of 4GL data types. Same as INTEGER. Automatically assigned by the engine. Floating-point numbers, of up to 16-digit precision. Whole numbers, from -32,767 to +32,767. Character strings of any length. Character strings of varying length, no greater than 255.



➀INFORMIX-OnLine

4GL Arithmetic Operators

Boolean Operators 4GL Relational Operators

Dynamic Server or other 4GL statements only.

➁SQL

only.

Operator Symbol

Operator Name

Name of Result

Precedence

** mod * / + -

exponentiation modulus multiplication division addition subtraction

power integer remainder product quotient sum difference

12 12 11 11 10 10

AND OR NOT

Operator Symbol Operator Name

Operator Symbol Operator Name

< = >

Less than Not greater than Equal to

Not equal to Not less than Greater than

Global Constants and Variables

Global Constants and Variables

FALSE INT_FLAG NOTFOUND NULL SQLCODE STATUS TRUE QUIT_FLAG

Built-In Functions

ARG_VAL(int-expr) ARR_COUNT( ) ARR_CURR( ) †AVG(int-field) †COUNT(*) DOWNSHIFT(char-expr) ERR_GET(int-expr) ERR_PRINT(int-expr) ERR_QUIT(int-expr) †Valid

11

SQLCA Record: SQLCODE SQLERRM SQLERRP SQLERRD SQLAWARN

ERRORLOG(char-expr) FGL_DRAWBOX(height,

NUM_ARGS( ) †PERCENT(*)

width,line,left-offset[,color])

SCR_LINE( ) SET_COUNT(int-expr) SHOWHELP(int-expr) SQLEXIT( ) STARTLOG(char-expr) †SUM(int-field) UPSHIFT(char-expr)

FGL_GETENV(char-expr) FGL_KEYVAL(char-expr) FGL_LASTKEY( ) LENGTH(char-expr) †MAX(int-field) †MIN(int-field)

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:

Operators

Number

Color

Number

Color

Number

Color

0 1 2

White Yellow Magenta

3 4 5

Red Cyan Green

6 7

Blue Black

ASCII int-expr char-expr CLIPPED COLUMN integer CURRENT CURRENT qualifier DATE DATE (date-expression) DAY(date-expression) EXTEND(time-value) EXTEND(time-value, qualifier) FIELD_TOUCHED(field-list) GET_FLDBUF(field-list) expression IS NOT NULL expression IS NULL INFIELD(field)

LENGTH(char-expr) †LINENO

MDY(int-expr, int-expr, int-expr) MONTH(date-expression) ORD(string-expr) †PAGENO int-expr SPACE int-expr SPACES TIME TODAY int-expr UNITS time-keyword expression USING format-string WEEKDAY (date-expression) †char-expr WORDWRAP YEAR (date-expression) †Valid only in REPORT blocks.

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

12

Library Functions Calling C Functions from 4GL

Library Functions

Popping Numbers

extern extern extern extern extern extern

void void void void void void

popint(int *iv) popshort(short *siv) poplong(long *liv) popflo(float *fv) popdub(double *dfv) 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

Calling 4GL Functions from C

Decimal Functions

fgl_start(filename, argc, argv) char *filename; int argc; char *argv[];

initialize resources for the 4GL environment

fgl_call(funcname, nparams) char *funcname; int nparams;

call the 4GL function

fgl_exitfm( )

reset terminal to character mode

fgl_end( )

free 4GL resources

deccvasc(cp, len, np) char *cp; int len; dec_t *np;

convert C char type to DECIMAL type

dectoasc(np, cp, len, right) dec_t *np; char *cp; int len; int right;

convert DECIMAL type to C char type

deccvint(integer, np) int integer; dec_t *np;

convert C int type to DECIMAL type

dectoint(np, ip) dec_t *np; int *ip;

convert DECIMAL type to C int type

deccvlong(lng, np) long lng; dec_t *np;

convert C long type to DECIMAL type

dectolong(np, lngp) dec_t *np; long *lngp;

convert DECIMAL type to C long type

deccvflt(flt, np) float flt; dec_t *np;

convert C float type to DECIMAL type

dectoflt(np, fltp) dec_t *np; float *fltp;

convert DECIMAL type to C float type

13

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

14

Decimal Functions

deccvdbl(dbl, np) double dbl; dec_t *np;

convert C double type to DECIMAL type

dectodbl(np, dblp) dec_t *np; double *dblp;

convert DECIMAL type to C double type

decadd(n1, n2, result) dec_t *n1; dec_t *n2; dec_t *result;

add two decimal numbers (result = n1 + n2)

decsub(n1, n2, result) dec_t *n1; dec_t *n2; dec_t *result;

subtract two decimal numbers (result = n1 - n2)

decmul(n1, n2, result) dec_t *n1; dec_t *n2; dec_t *result;

multiply two decimal numbers (result = n1 * n2)

decdiv(n1, n2, result) dec_t *n1; dec_t *n2; dec_t *result;

divide two decimal numbers (result = n1 / n2)

int deccmp(n1, n2) dec_t *n1; dec_t *n2;

compare two decimal numbers

deccopy(n1, n2) dec_t *n1; dec_t *n2;

copy a decimal number

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) dec_t *np; int ndigit; int *decpt; int *sign;

convert decimal value to ASCII string

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 DISPLAY ARRAY

DISPLAY FORM ERROR INPUT

INPUT ARRAY MESSAGE 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 Attribute

Monochrome Display

Intensity Attribute

Color Display

WHITE YELLOW MAGENTA RED CYAN GREEN BLUE BLACK

NORMAL BOLD BOLD BOLD DIM DIM DIM DIM

NORMAL BOLD DIM

WHITE RED BLUE

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

16

Command-Line Syntax

CommandLine Syntax c4gl -ansi

-e

-a

-anyerr

source.4gl -o outfile

-args

esqlc.ec source.c obj.o yourlib -V

cfglgo

cfile

fgiusr.c

-o newfglgo

.ec .c .o -V cfile

fglgo

filename -a

argument

-anyerr

.4go .4gi -V

fglpc

source -ansi

-a

-p pathname

-anyerr -V

finderr

msg_num

.4gl

Command-Line Syntax

form-name

form4gl -q

-l lines -c characters

-V

-d

mkmessage

17

in file

form-name

databasename

tablename

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). Preparing SQL statements is described in Chapter 3 of the INFORMIX-4GL Reference.

Types of SQL Statements

SQL Data Definition Statements ALTER INDEX ALTER TABLE CLOSE DATABASE CREATE DATABASE CREATE INDEX CREATE SYNONYM

CREATE TABLE CREATE VIEW DATABASE DROP DATABASE DROP INDEX DROP SYNONYM

DROP TABLE DROP VIEW RENAME COLUMN RENAME TABLE

SQL Data Manipulation Statements INSERT DELETE

LOAD SELECT

UNLOAD UPDATE

SQL Cursor Manipulation Statements CLOSE DECLARE

FETCH FLUSH

OPEN PUT

SQL Query Optimization Information Statements SET EXPLAIN

SET OPTIMIZATION

UPDATE STATISTICS

SQL Data Access Statements GRANT LOCK TABLE

REVOKE SET ISOLATION

OL

SET LOCK MODE UNLOCK TABLE

SQL Data Integrity Statements SE SE

BEGIN WORK CHECK TABLE COMMIT WORK CREATE AUDIT

SE SE SE

DROP AUDIT RECOVER TABLE REPAIR TABLE ROLLBACK WORK

Note: The data integrity statements marked with the only by the INFORMIX-SE engine. Statements marked INFORMIX-OnLine Dynamic Server engine.

SE OL OL SE SE OL

ROLLFORWARD DATABASE SET CONSTRAINTS SET LOG START DATABASE

symbol are supported can only be used with the

Other Types of 4GL Statements

21

SQL Dynamic Management Statements EXECUTE FREE

Other Types of 4GL Statements

PREPARE

4GL Definition and Declaration Statements DEFINE FUNCTION

MAIN REPORT

4GL Program Flow Control Statements CALL CASE CONTINUE DATABASE END EXIT

FINISH REPORT FOR FOREACH GOTO IF LABEL

OUTPUT TO REPORT RETURN RUN START REPORT WHILE

4GL Compiler Directives DATABASE DEFER

GLOBALS WHENEVER

4GL Storage Manipulation Statements INITIALIZE LET

LOCATE VALIDATE

4GL Screen Interaction Statements CLEAR CLOSE FORM CLOSE WINDOW CONSTRUCT CURRENT WINDOW DISPLAY DISPLAY ARRAY

DISPLAY FORM ERROR INPUT INPUT ARRAY MENU MESSAGE OPEN FORM

OPEN WINDOW OPTIONS PROMPT SCROLL SLEEP

4GL Report Execution Statements NEED PAUSE

PRINT SKIP

Most 4GL statements are not sensitive to whether the SE or the OnLine engine supports the application. Only the OnLine engine, however, can store values in BYTE, TEXT, or VARCHAR columns, or can accept database: or database@system: as qualifiers to names of tables, views, or synonyms.

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

22

CALL

(

CALL function

) ,

,

4GL Expression p. 39

RETURNING

Receiving Variable p. 29

Case I: (single criterion)

(

CASE

4GL Expression (subset) p. 39

)

WHEN

4GL Expression (subset) p. 39

statement

END CASE

EXIT CASE OTHERWISE Block

Case II: (multiple criteria) statement

4GL Boolean Expression p. 40

WHEN

EXIT CASE

OTHERWISE Block

statement

OTHERWISE

EXIT CASE

CLEAR

FORM

window

WINDOW

, Field Clause p. 46

CLOSE FORM form

CLOSE WINDOW window

SCREEN

CONSTRUCT

CONSTRUCT

CONSTRUCT Variable Clause

ATTRIBUTE Clause p. 37

23

HELP number CONSTRUCT Form Management Block

END CONSTRUCT

,

CONSTRUCT Variable Clause

variable ON

Column List

BY NAME variable ON

Column List

FROM

Field Clause p. 46

, Column List

column Table Qualifier p. 46

table . table . *

Table Qualifier p. 46

CONSTRUCT Form Management Block 1

BEFORE CONSTRUCT

1

AFTER CONSTRUCT

BEFORE FIELD AFTER FIELD ON KEY

statement NEXT FIELD

,

NEXT

field

Field Clause p. 46

, (

key

CONTINUE CONSTRUCT

)

CONTINUE keyword

CURRENT WINDOW IS

PREVIOUS

window SCREEN

EXIT CONSTRUCT

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

24

DEFER

DEFER

INTERRUPT QUIT

, DEFINE

variable

Data Type Declaration p. 37

Case I: (output in the Line mode overlay)

, DISPLAY Value

DISPLAY

COLUMN left-offset

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

,

AT line, left-offset

DISPLAY Value

ATTRIBUTE Clause p. 37

Case III: (in a screen form)

, ,

, TO

DISPLAY Value

Field Clause p. 46

, variable

BY NAME

ATTRIBUTE Clause p. 37

DISPLAY Value

value CLIPPED USING

"format string "

ASCII number

DISPLAY ARRAY record array TO screen array .

* ATTRIBUTE Clause p. 37

ON KEY Block p. 25

END DISPLAY

DISPLAY FORM

25

,

ON KEY Block

(

ON KEY

)

key name

statement EXIT DISPLAY

DISPLAY FORM form ATTRIBUTE Clause p. 37

keyword

END

These are valid keywords in the END statement: CASE CONSTRUCT DISPLAY FOR

FOREACH FUNCTION GLOBALS IF

INPUT MAIN MENU

PROMPT REPORT WHILE

, 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 CONSTRUCT DISPLAY

FINISH REPORT report

FOR FOREACH INPUT

MENU PROMPT WHILE

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

26

FOR

FOR counter = start TO finish

statement STEP increment

END FOR

CONTINUE FOR EXIT FOR

FOREACH cursor

statement

,

CONTINUE FOREACH

Variable List

INTO

END FOREACH

EXIT FOREACH

,

Variable List

variable

.

.* . first

record

, array

FUNCTION function

(

[

3

, argument

THROUGH

record . last

THRU

Integer Expression p. 41

]

) )

END FUNCTION

DEFINE Statement p. 24

Case I: (declaring and exporting variables)

, GLOBALS

DEFINE Statement p. 24

Case II: (importing variables)

"filename"

END GLOBALS

statement RETURN Statement p. 35

GOTO

GOTO

27

label name

:

IF

4GL Boolean Expression p. 40

statement

THEN

END IF

statement

ELSE

, INITIALIZE

Variable List

table

LIKE

.column .*

Table Qualifier p. 46 TO NULL

,

Variable List

variable

.

.* . first

record

THROUGH

, array

INPUT

Binding Clause p. 28

[

ATTRIBUTE Clause p. 37

3

record . last

THRU

Integer Expression p. 41

]

HELP number INPUT Form Management Block

END INPUT

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

28

INPUT ARRAY

,

Binding Clause

, Field Clause field (subset) p. 46

FROM

variable

,

WITHOUT DEFAULTS

variable

BY NAME

WITHOUT DEFAULTS INPUT Form Management Block

, BEFORE

FIELD

AFTER

INPUT

Field Clause p. 46

statement NEXT FIELD

field

, ON KEY

(

key

NEXT

)

EXIT

PREVIOUS

CONTINUE

INPUT

Acceptable values of key (in lowercase or uppercase letters) for the ON KEY block are: ACCEPT HELP NEXT or DELETE INSERT NEXTPAGE DOWN INTERRUPT PREVIOUS or ESC or ESCAPE LEFT PREVPAGE F1 through F64 CONTROL-char (except A, D, H, I, J, L, M, R, or X)

RETURN or ENTER RIGHT TAB UP

Built-in functions that access field buffers and keystroke buffers:

INPUT ARRAY

Built-In Funtion

Description

FIELD_TOUCHED(field) GET_FLDBUF(field-list) FGL_LASTKEY( ) INFIELD(field)

Returns TRUE when the user has made a change to screen field. Returns the character values of the contents of one or more fields. Returns an INTEGER value corresponding to the most recent keystroke. Returns TRUE if field is the name of the current screen field.

Binding Clause ATTRIBUTE Clause p. 37

HELP number INPUT ARRAY Form Management Block

END INPUT

Binding Clause

program array

FROM screen array WITHOUT DEFAULTS

.*

LABEL

INPUT ARRAY Form Management Block

29

, BEFORE

FIELD

AFTER

INPUT

Field Clause p. 46

statement NEXT FIELD

Field Clause field p. 46

DELETE NEXT INSERT

EXIT

ROW

CONTINUE

, (

ON KEY

PREVIOUS INPUT

)

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 program array, and the screen array: Function

Description

ARR_CURR( )

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

ARR_COUNT( ) SCR_LINE( ) SET_COUNT(filled-rows)

LABEL label identifier

: ,

LET

=

Receiving Variable

4GL Expression p. 39

= NULL destination .* = source . *

blob

Receiving Variable simple variable

record

. ,

array [

3

Integer Expression p. 41

]

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

30

LOAD

"filename"

LOAD FROM

file variable

insert variable

"character"

DELIMITER

INSERT Clause

delimiter

INSERT Clause

table

INSERT INTO

,

Table Qualifier p.46

(

column

)

, LOCATE

IN

BYTE or TEXT Variable

MEMORY

"filename"

FILE

variable

BYTE or TEXT Variable

variable

.

.* .first

record

, array

[

3

integer

record

]

statement DEFINE Statement p. 24

"title " variable

. last

THRU

MAIN

MENU

THROUGH

DATABASE Statement p. 72

MENU Control Block

EXIT PROGRAM DEFER Statement p. 24

END MENU

END MAIN

MESSAGE

31

MENU Control Block BEFORE MENU

statement

COMMAND Block

NEXT OPTION option name

, SHOW

OPTION

HIDE

option name ALL

CONTINUE MENU EXIT MENU

COMMAND Block COMMAND

option name

,

option description

3

KEY (

key

)

HELP number

, MESSAGE

"string" variable

OPEN FORM form FROM

ATTRIBUTE Clause p. 37

"filename"

OPEN WINDOW window AT top-line , left-offset WITH

height ROWS , width COLUMNS FORM

"filename" variable

OPEN WINDOW ATTRIBUTE Clause p. 32

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

32

OPEN WINDOW

,

OPEN WINDOW Attribute Clause ATTRIBUTE

(

)

REVERSE BORDER

WHITE YELLOW

COMMENT LINE

MAGENTA

FORM LINE

RED

MENU LINE

CYAN

MESSAGE LINE

GREEN

PROMPT LINE

Reserved Line Position

BLUE BLACK

NORMAL BOLD DIM

Attribute

Default Setting

color REVERSE BORDER PROMPT LINE line value MESSAGE LINE line value MENU LINE line value FORM LINE line value COMMENT LINE line value

Default foreground color on your terminal No reverse video No border FIRST (=1) FIRST + 1 (=2) FIRST (=1) FIRST + 2 (=3) LAST - 1 (for the 4GL screen) LAST (for all other 4GL windows)

Reserved Line Position FIRST

+ integer

LAST

OPTIONS

33

, OPTIONS

FIRST

LINE

COMMENT

+

ERROR FORM

number

MENU

-

MESSAGE LAST

PROMPT

KEY key

ACCEPT DELETE INSERT NEXT PREVIOUS

FILE "filename"

HELP DISPLAY

ATTRIBUTE

INPUT

WRAP

OPTIONS ATTRIBUTE Clause p. 34

NO WRAP FIELD ORDER

UNCONSTRAINED CONSTRAINED

SQL INTERRUPT

ON OFF

Clause

Default

COMMENT LINE ERROR LINE FORM LINE MENU LINE MESSAGE LINE PROMPT LINE ACCEPT KEY DELETE KEY INSERT KEY NEXT KEY PREVIOUS KEY HELP KEY HELP FILE

LAST - 1 for the 4GL screen LAST for all other 4GL windows LAST line of the 4GL screen FIRST + 2 or line 3 of the current 4GL window FIRST line of the 4GL window FIRST + 1 or line 2 of the current 4GL window FIRST line of the 4GL window ESCAPE F2 F1 F3 F4 CONTROL-W None

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

34

OUTPUT TO REPORT

,

OPTIONS ATTRIBUTE Clause ATTRIBUTE

(

)

BLINK REVERSE

BLACK

UNDERLINE

BLUE CYAN GREEN

BOLD

MAGENTA

DIM

RED

INVISIBLE

WHITE

NORMAL FORM

YELLOW

WINDOW

, OUTPUT TO REPORT report

(

)

4GL Expression p. 39 blob

, PROMPT

"string" variable

response

FOR

HELP number

ATTRIBUTE Clause p. 37

ATTRIBUTE Clause p. 37

CHAR

, ON KEY

For values for key, see p. 28.

(

key

)

statement

END PROMPT

REPORT

REPORT report

(

)

,

FORMAT Section p. 58

)

argument

35

END REPORT

DEFINE Statement p. 24 OUTPUT Section p. 56

ORDER BY Section p. 57

RETURN

, 4GL Expression p. 39

RUN

"command " character variable

RETURNING integer variable WITHOUT WAITING

, SCROLL

Field Clause p. 46

DOWN BY lines

UP

SLEEP

Integer Expression p. 41

START REPORT report

"filename"

TO

PRINTER PIPE

"command " variable

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

36

UNLOAD

"filename"

UNLOAD TO

select variable

"character"

DELIMITER

file variable

SELECT Statement p. 82

delimiter variable

, VALIDATE

Variable List

table

LIKE Table Qualifier p. 46

.column .*

,

Variable List

variable

.

.* . first

record

THROUGH

, array

WHENEVER

[

3

]

Integer Expression p. 41

CONTINUE

ANY

WHILE

4GL Boolean Expression p. 40

+

+ ERROR

GOTO

SQLWARNING

STOP

WARNING

statement EXIT WHILE CONTINUE WHILE

: label

GO TO

SQLERROR

+

. last

THRU

NOT FOUND

+

record

CALL function

END WHILE

label

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

table

LIKE

. 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 BYTE

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

38

4GL Simple Data Type

4GL Simple Data Type INTEGER INT SMALLINT

(16)

DECIMAL

( precision

DEC

, scale

NUMERIC

, scale

) ( precision

,2

)

(16, 2)

MONEY FLOAT

( precision )

DOUBLE PRECISION SMALLFLOAT REAL DATE DATETIME

DATETIME Qualifier p. 44

INTERVAL

INTERVAL Qualifier p. 45

(1)

CHARACTER

(

CHAR

size

)

, reserve size ,0

( maximum size

VARCHAR

,

Array Data Type ARRAY

[

3

size

]

OF

4GL Simple Data Type p. 38 RECORD Data Type p. 39 BYTE TEXT

)

RECORD Data Type

RECORD Data Type

39

, member

RECORD

Data Type Declaration p. 37

END RECORD

table .*

LIKE 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

Function Call

function

(

, 4GL Expression p. 39

)

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

40

4GL Boolean Expression

AND

4GL Boolean 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 p. 39

=

4GL Expression p. 39

< > = != String Comparison Character Expression p. 42

MATCHES NOT

LIKE

criterion 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 p. 39

IS

NULL NOT

blob variable

Set Membership Test

, 4GL Expression p. 39

IN

(

4GL Expression p. 39

)

NOT

Case I: Pure integers Integer Expression Literal Integer p. 42

+ -

Function Call p. 39 Named Value p. 39 4GL Boolean Expression p. 40

Case II: Differences between DATE values DATE Value p. 43

-

DATE Value p. 43

+ * / MOD

**

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

42

Literal Integer

Literal Integer

digit

+ Number Expression

+ * /

Literal Number

+ -

Named Value p. 39 Function Call p. 39

Integer Expression p. 41

MOD 4GL Boolean Expression p. 40

**

Literal Number

digit

-

. .

+ -

digit

digit

E

+

e

Character Expression

"

character

"

Function Call p. 39 Named Value p. 39

USING "format-string"

CLIPPED

[

]

Integer 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

" USING "format string"

Function Call 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 DATETIME Qualifier p. 44

CURRENT EXTEND (

DATETIME Value DATE Value

) ,

DATETIME Qualifier p. 44

INTERVAL Value

"

Numeric Time Interval p. 46

+ -

" INTERVAL Literal p. 45

Function Call p. 39 Named Value p. 39 Integer Expression p. 41

UNITS keyword

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

44

Numeric Date

Numeric Date

yy

mo 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

INTERVAL Qualifier

45

Case I: Time units smaller than MONTH DAY

HOUR

(precision) ( 2)

TO DAY

(precision) ( 2)

TO HOUR

(precision) ( 2)

TO MINUTE

(precision) ( 2)

TO SECOND

MINUTE

SECOND

TO FRACTION

FRACTION

( scale ) ( 3)

Case II: Time units greater than DAY YEAR

MONTH

(y-precision) ( 4) (precision) ( 2)

TO YEAR

TO MONTH

INTERVAL Literal INTERVAL

(

Numeric Time Interval p. 46

)

INTERVAL Qualifier

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

*

[ line ] [1]

screen array

THRU Notation

FORMONLY

Table Qualifier

OL

owner.

:

database @server

THRU Notation

first

THROUGH THRU

same.last

"owner."

4GL Forms

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

48

DATABASE Section

Form Specification Syntax DATABASE

ATTRIBUTES Section p. 49

SCREEN Section

Section

TABLES Section p. 49

INSTRUCTIONS Section p. 49

DATABASE Section FORMONLY

DATABASE

DATABASE Section database Database Reference

WITHOUT NULL INPUT

DATABASE Section Database Reference

database database @server

"/ / server / database"

OL

"/ pathname / database @server"

SE

"/ / server / pathname / database"

SCREEN Section

{

SCREEN SIZE lines

Screen Layout

BY characters

} END

Screen Layout

[ [

field-tag

field-tag

|

] field-tag

]

character

TABLES Section

49

TABLES Section

table

TABLES

alias =

Table Qualifier p. 46

END

ATTRIBUTES Section ATTRIBUTES

field-tag

=

;

Field Description

END

Field Description

column FORMONLY. field name

TYPE

table .

LIKE

data-type

NOT NULL

, ,

Attributes p. 50

INSTRUCTIONS Section INSTRUCTIONS

SCREEN RECORD

record array

DELIMITERS

(

[ size ]

Field List p. 50

) END

" 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 BLUE CYAN GREEN

REVERSE LEFT BLINK UNDERLINE

MAGENTA RED WHITE YELLOW

Boolean Expressions for 4GL Forms

Boolean Expressions for 4GL Forms

51

AND OR 4GL Expression (Subset) p. 39

NOT

= < > = !=

field-tag

IS

4GL Expression (Subset) p. 39

field-tag TRUE FALSE

NULL

NOT

NOT

field-tag

BETWEEN

4GL Expression (Subset) p. 39

field-tag

AND

4GL Expression (Subset) p. 39

, IN

(

4GL Expression (Subset) p. 39

)

field-tag Character Expression p. 42

MATCHES

"

character

"

LIKE

(

ESCAPE Boolean Expression for 4GL Forms

"char "

)

COMMENTS Attribute COMMENTS

= "message "

DEFAULT Attribute DEFAULT

=

value

DISPLAY LIKE Attribute

column

DISPLAY LIKE

table .

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

52

DOWNSHIFT Attribute

DOWNSHIFT Attribute DOWNSHIFT

FORMAT Attribute

= "format-string"

FORMAT

For DATE data types, format-string consists of: Special Characters mm mmm dd ddd yy yyyy

Meaning 2-digit representation of the month 3-letter abbreviation of the month 2-digit representation of the day of the month 3-letter abbreviation of the day of the week 2-digit representation of the year, discarding the leading digits 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 A # X

Meaning Any letter Any digit Any character

PROGRAM Attribute PROGRAM

= "command "

REQUIRED Attribute REQUIRED

REVERSE Attribute REVERSE

UPSHIFT Attribute UPSHIFT

VALIDATE LIKE Attribute

column

VALIDATE LIKE

table .

VERIFY Attribute VERIFY

Basics 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

(

)

, argument

FORMAT Section p. 58

)

DEFINE Section

OUTPUT Section p. 56

DEFINE Section

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

variable

DEFINE

OUTPUT Section OUTPUT

1

END REPORT

REPORT TO

"filename " PRINTER

1

LEFT

1

TOP

1

BOTTOM

1

RIGHT

1

PAGE LENGTH

size

1

TOP OF PAGE

"string "

PIPE MARGIN

"command " variable

ORDER BY Section p. 57

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 EXTERNAL

argument ASC DESC

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

58

FORMAT Section

FORMAT Section EVERY ROW

FORMAT

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 BEFORE GROUP OF b BEFORE GROUP OF c ON EVERY ROW AFTER GROUP OF c AFTER GROUP OF b AFTER GROUP OF a

{1} {2} {3} {4} {3} {2} {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

statement

ON LAST ROW

statement

PAGE TRAILER

statement

ON EVERY ROW Control Block

ON LAST ROW Control Block

PAGE TRAILER Control Block

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

RIGHT MARGIN temporary

WORDWRAP

TEXT variable FILE

" filename"

Aggregate Report Functions PERCENT

(*)

COUNT

GROUP

AVG

(

Number Expression p. 42

)

SUM

SKIP

MAX

(

MIN

(

TO TOP OF PAGE

integer

LINE LINES

INTERVAL Value p. 43 4GL Expression p. 39

) )

WHERE

4GL Boolean Expression p. 40

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 SE SE by the 6.0 icon nor SQL statements containing a clause identified by the 6.0 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).

+ ALTER INDEX

Index Name p. 92

TO

CLUSTER NOT

,

+ ALTER TABLE

Table Name p. 92

ADD Clause

Synonym Name p. 92

DROP Clause p. 63 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

6.0

Add Column Clause p. 63

, (

Add Column Clause p. 63

)

ALTER TABLE

Add Column Clause

new column name

SQL Data Type p. 93

,

NOT NULL

6.0

63

Column-Level Constraint Definition p. 68

DEFAULT Clause p. 67 BEFORE column name

DROP Clause DROP

column name

6.0

, (

column name

MODIFY Clause MODIFY

6.0

)

Modify Column Clause

, (

Modify Column Clause

column name

Modify Column Clause

SQL 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 Definition p. 68

ADD CONSTRAINT

,

6.0

(

DROP CONSTRAINT Clause 6.0

DROP CONSTRAINT

Constraint Definition p. 68

)

Constraint Name p. 92

, (

Constraint Name p. 92

MODIFY NEXT SIZE Clause MODIFY NEXT SIZE kbytes

LOCK MODE Clause LOCK MODE

(

PAGE ROW

+ BEGIN WORK

CLOSE

Cursor Name p. 92

)

)

CLOSE DATABASE

65

+ CLOSE DATABASE

COMMIT WORK

SE

+ Table Name p. 92

CREATE AUDIT FOR

IN

"pathname"

Synonym Name p. 92

+ CREATE DATABASE

Database Name p. 93

" databasename "

OL

IN dbspace

SE

SE Log Clause

OL

OL Log Clause

SE Log Clause WITH LOG IN " pathname " MODE ANSI OL Log Clause WITH

LOG BUFFERED LOG MODE ANSI

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

66

CREATE INDEX

+ Index Name p. 92

INDEX

CREATE UNIQUE

CLUSTER

ON Clause OL 6.0

DISTINCT FILLFACTOR

, ON Clause

(

Table Name p. 92

ON

)

column name ASC

Synonym Name p. 92

DESC

6.0

+ CREATE PROCEDURE FROM

"

filename

"

Named Value p. 103

+ SYNONYM

CREATE

Synonym Name p. 92

FOR

Table Name p. 92

6.0 PUBLIC PRIVATE

View Name p. 92

percent

CREATE TABLE

, CREATE

Table Name p. 92

TABLE

,

Column Definition p. 67

(

67

,

Constraint Definition p. 68

) Storage Option p. 69

, +

TEMP TABLE

temp table name

Temp Table Column Definition

(

, ,

Temp Table Constraint Definition p. 68

)

WITH NO LOG

Column Definition

column

SQL Data Type p. 93 6.0

NOT NULL DEFAULT Clause

Column-Level Constraint Definition

Temp Table Column Definition

column

SQL Data Type p. 93

6.0

NOT NULL DEFAULT Clause

DEFAULT Clause DEFAULT

Temp Table Column Constraint p.68

Constant Expression p. 97 NULL

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

68

CREATE TABLE

Column-Level Constraint Definition UNIQUE

+

+

CONSTRAINT

DISTINCT 6.0

Constraint Name 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

6.0

DISTINCT PRIMARY KEY FOREIGN KEY

(

, column

CHECK Clause p. 69

)

REFERENCES Clause p. 69

Constraint Name p. 92

CREATE TABLE

Temp-Table Constraint Definition

69

, (

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

SE

IN

Extent Option

LOCK MODE Clause p. 70

"pathname "

Extent Option

EXTENT SIZE first kpages

NEXT SIZE next kpages

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

70

CREATE TRIGGER

LOCK MODE Clause LOCK MODE PAGE ROW

6.0

+ Trigger Name

CREATE TRIGGER

INSERT

ON

Table Name p. 92

Action Clause p. 71 Insert REFERENCING Clause p. 71

DELETE

ON

Table Name p. 92

Action Clause 71 Delete REFERENCING Clause p. 71

UPDATE Clause p. 71

ON

Table Name p. 92

Action Clause Referencing p. 72

Action Clause p. 71 Update REFERENCING Clause p. 72

Trigger Name Identifier p. 100

owner.

Action Clause Referencing p. 72

Action Clause Referencing p. 72

CREATE TRIGGER

71

UPDATE Clause UPDATE

, OF

column name

Action Clause BEFORE

Triggered Action List p. 72

FOR EACH ROW

FOR EACH ROW

Triggered Action List p. 72

Triggered Action List p. 72 AFTER

AFTER

AFTER

Triggered Action List p. 72

Triggered Action List p. 72

Triggered Action List p. 72

INSERT REFERENCING Clause REFERENCING

correlation name

NEW AS

DELETE REFERENCING Clause REFERENCING

correlation name

OLD AS

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

72

CREATE VIEW

UPDATE REFERENCING Clause 1

REFERENCING

correlation name

OLD AS

1

correlation name

NEW AS

ACTION Clause Referencing FOR EACH ROW BEFORE

Triggered Action List

Triggered Action List

,

Triggered Action List

, INSERT Statement p. 77

( (

WHEN

Condition p. 91

Triggered Action List

AFTER

)

)

DELETE Statement p. 73 UPDATE Statement p. 88 EXECUTE PROCEDURE p. 75

CREATE VIEW

View Name p. 92

, (

+ DATABASE

AS

column name

)

Database Name p. 93 EXCLUSIVE

SELECT (Subset) p. 82

WITH CHECK OPTION

DECLARE

DECLARE

Cursor Name p. 92

CURSOR

FOR

73

INSERT Statement (Subset) p. 77

+

+ WITH HOLD

SELECT FOR Statement (Subset) UPDATE p. 82

+

+ SCROLL CURSOR

,

FOR WITH HOLD

OF

column

SELECT Statement p. 82 Prepared Statement Name p. 103

DELETE FROM

Table Name p. 92 WHERE View Name p. 92 Synonym Name p. 92

Condition p. 91

CURRENT OF

Cursor Name p. 92

SE

+ DROP AUDIT FOR

Table Name p. 92 Synonym Name p. 92

+ DROP DATABASE

Database Name p. 93

" databasename "

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

74

+ DROP INDEX

DROP INDEX

Index Name p. 92

6.0

+ DROP PROCEDURE

+ DROP SYNONYM

Procedure Name p. 92

Synonym Name p. 92

+ DROP TABLE

Table Name p. 92 Synonym Name p. 92

6.0

+ DROP TRIGGER

Trigger Name p. 70

DROP VIEW

View Name p. 92

+

Synonym Name p. 92

EXECUTE

+

Prepared Statement Name p. 103

EXECUTE

75

, Named Value p. 103

USING

6.0

+ Procedure Name p. 92

EXECUTE PROCEDURE

(

) ,

,

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 Name p. 92

FETCH

+

INTO

data variable

+

NEXT PREVIOUS PRIOR FIRST LAST CURRENT RELATIVE

ABSOLUTE

+ FLUSH

Cursor Name p. 92

+

row position

-

Named Value p. 103

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

76

FREE

+

TEXT or BYTE Named Value p. 103

FREE

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 variable 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.

+

GRANT

DatabaseLevel Privileges p. 81

PUBLIC

TO

, user

TableLevel Privileges p. 77

ON

Table Name p. 92

TO

PUBLIC

View Name p. 92 Synonym Name p. 92

6.0

EXECUTE ON

Procedure Name p. 92

WITH GRANT OPTION

, user

+

AS grantor

INSERT INTO

77

Table-Level Privileges ALL PRIVILEGES

, 1

INSERT

1

DELETE

1

SELECT

,

+

( 1

UPDATE

,

+

( 1

6.0

INSERT INTO

INDEX

1

ALTER

REFERENCES

Table Name p. 92 View Name p. 92

)

column name

, (

1

)

column name

)

column name

VALUES Clause p. 78

, (

)

column name

SELECT Statement (Subset) p. 82

Synonym Name p. 92 6.0

EXECUTE PROCEDURE

Procedure Name p. 92

(

, Argument p. 78

)

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

78

INSERT INTO

Argument

SPL Expression p. 112

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

,

VALUES Clause

Named Value p. 103

VALUES (

)

NULL Constant Expression p. 97 Record Reference p. 104 Record Reference p. 104

.*

. member THRU

Record Reference p. 104

. member

LOAD FROM

79

+

" filename "

LOAD FROM

Named Value p. 103

"delimiter"

DELIMITER

Named Value p. 103

Table Name p. 92

INSERT INTO

,

Synonym Name p. 92

LOCK TABLE

Table Name p. 92

IN

SHARE

)

MODE

EXCLUSIVE

Synonym Name p. 92

OPEN

column

View Name p. 92

Named Value p. 103

+

(

Cursor Name p. 92

, USING

PREPARE

Prepared Statement Name p. 103

FROM

Named Value p. 103

Quoted String p. 104 Named Value p. 103

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

80

PUT

+ PUT

Cursor Name p. 92

, FROM

Named Value p. 103

SE

+

Table Name p. 92

RECOVER TABLE

+

Table Name p. 92

RENAME COLUMN

. old column TO new column

+ RENAME TABLE

old name TO new name owner

.

+ REVOKE

Table-Level Privileges p. 81

ON

Table Name p. 92 View Name p. 92 Synonym Name p. 92

6.0

EXECUTE ON

Database-Level Privileges p. 81

Procedure Name p. 92

FROM

PUBLIC

,

user

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

+ ROLLFORWARD DATABASE

Database Name p. 93

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

82

SELECT

UNION UNION ALL FROM Clause p. 83

Select Clause

SELECT

INTO Clause p. 83

WHERE Clause p. 84

GROUP BY Clause p. 85

HAVING Clause p. 85

+

ORDER BY Clause p. 86

, SELECT Clause ALL DISTINCT

+ UNIQUE

Select Item p. 83

INTO TEMP Clause p. 86

SELECT

Select Item

83

SQL Expression p. 96

display label

+ AS

* Table Name p. 92

.

View Name p. 92

.

Synonym Name p. 92

.

, INTO Clause INTO

FROM Clause FROM

Named Value p. 103

Table Name p. 92 View Name p. 92 Synonym Name p. 92

table alias

+

,

Additional Tables p. 84

AS

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 OUTER

Table Name p. 92

table alias

View Name p. 92

AS

Synonym Name p. 92

OUTER (

Table Name p. 92

) table alias

View Name p. 92

AS

Synonym Name p. 92

AND WHERE Clause WHERE

Condition p. 91 Join p. 85

,

Additional Tables

SELECT

Join

column name

Relational Operator p. 104

column name

.

Table Name p. 92

.

table alias

.

table alias

.

View Name p. 92

.

View Name p. 92

.

Synonym Name p. 92

.

Synonym Name p. 92

.

Table Name p. 92

85

, GROUP BY Clause

column name

GROUP BY

+

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

column name

ORDER BY Table Name p. 92

.

table alias

.

View Name p. 92

.

Synonym Name p. 92

.

ASC DESC

select number display label rowid

INTO TEMP Clause INTO TEMP temp table name WITH NO LOG

6.0 OL

+ SET CONSTRAINTS

ALL

IMMEDIATE

,

DEFERRED

Constraint Name p. 92

6.0

+ SET DEBUG FILE TO

"

filename

"

Named Value p. 103

character expression

WITH APPEND

SET EXPLAIN

87

+ OFF

SET EXPLAIN

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 OPTIMIZATION

HIGH LOW

SE

+ START DATABASE

Database Name p. 93

WITH LOG IN "pathname" MODE ANSI

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

88

UNLOAD

+

SELECT Statement p. 82

" filename "

UNLOAD TO

DELIMITER Named Value p. 103

" delimiter " Named Value p. 103

+

Table Name p. 92

UNLOCK TABLE

Synonym Name p. 92

UPDATE

Table Name p. 92 View Name p. 92 Synonym Name p. 92

SET

SET Clause p. 89 WHERE

Condition p. 91

CURRENT OF

Cursor Name p.92

UPDATE

89

,

SET Clause

column name

=

SQL Expression (Subset) p. 96 SELECT Statement (Subset) p. 82 Record Reference p. 104

,

, (

. member

column name

)

=

(

*

SELECT Statement (Subset) p. 82

Table Name p. 92

.*

View Name p. 92

.*

Referenced Values

Synonym Name p. 92

.*

Referenced Values

Referenced Values

(

Record Reference p. 104

Record Reference p. 104

Record Reference p. 104

)

SQL Expression (Subset) p. 96

)

.*

. member

. member THRU

Record Reference p. 104

. member Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

90

UPDATE STATISTICS

+ UPDATE STATISTICS

6.0

FOR PROCEDURE Procedure Name p. 92

6.0

FOR TABLE

LOW

6.0 Table Specification

DROP DISTRIBUTIONS

6.0 MEDIUM FOR TABLE

conf

Table Specification

RESOLUTION percent

Table Specification

RESOLUTION percent

HIGH FOR TABLE

Table Specification Table Name p. 92

,

6.0 Synonym Name p. 92

NOT FOUND

WHENEVER

column

(

)

CONTINUE

SQLERROR

+

GOTO

label

GO TO

:label

+ ERROR STOP ANY CALL function name WARNING 6.0 SQLWARNING

91

Condition

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 p. 96

Relational Operator p. 104

SQL Expression p. 96

BETWEEN SQL Expression AND SQL Expression p. 96 p. 96

SQL Expression p. 96 NOT

, +

SQL Expression p. 96

IN

(

Constant Expression p. 97

)

NOT Column Expression p. 96

IS

NULL NOT

Column Expression p. 96

LIKE NOT

+ MATCHES

Quoted String p. 104 Named Value p. 103

ESCAPE "character"

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

92

IN Subquery

IN Subquery SQL Expression p. 96

IN (

SELECT (Subset) p. 82

)

NOT

EXISTS Subquery

SELECT (Subset) p. 82

EXISTS (

)

NOT

ALL/ANY/SOME Subquery

SQL Expression p. 96

Relational Operator p. 104

(

SELECT (Subset) p. 82

ALL ANY SOME Constraint Name Index Name Procedure Name Synonym Name Table Name View Name Identifier p. 100

' owner.'

OL

:

database @dbservername

Cursor Name

Identifier p. 100

)

93

Database Name

Database Name Identifier p. 100 OL

OL

@dbservername

"//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

( size )

CHARACTER

6.0 NLS +

(1 ) NCHAR

OL +

( maximum

VARCHAR

) , reserve

6.0 NLS

,0 NVARCHAR

Number Data Type INTEGER INT

+

SERIAL

(1 ) (start) SMALLINT FLOAT

( float precision )

DOUBLE PRECISION SMALLFLOAT

+

REAL DECIMAL

(

DEC

16

NUMERIC

+

)

precision

, 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

+

IN

BYTE

TABLE

blobspace

DATETIME Field Qualifier YEAR MONTH DAY HOUR

TO YEAR TO MONTH 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

.

table alias

.

View Name p. 92

.

Synonym Name p. 92

.

+

[first, last ]

+ ROWID

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 EXTEND

)

nondate expression

(

)

date expression datetime expression

MDY

LENGTH

month integer expression

(

,

(

day integer expression

,

DATETIME Field Qualifier p. 95

,

year integer expression

)

Quoted String p. 104

variable name column name Table Name p. 92

.

( integer expression )

HEX

Algebraic Functions p.99

6.0 Procedure Name p. 92

(

SPL Expression p. 112

DBINFO Function p. 99 Exponential and Logarithmic Functions p. 99 Trigonometric Functions p. 100

)

)

Algebraic Functions

Algebraic Functions ROUND

(

SQL Expression p. 96

99

) , rounding factor ,0

TRUNC

(

SQL Expression p. 96

6.0

) , truncating factor ,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 LOGN LOG10

( ( (

float expression float expression float expression

) ) )

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

100

Trigonometric Functions

Trigonometric Functions COS

(

radian expression

)

(

numeric expression

)

SIN TAN ASIN ACOS ATAN

(

ATAN2

y, x

)

Aggregate Expression COUNT (*)

(

AVG MAX MIN SUM COUNT

column name DISTINCT

Table Name p. 92

)

.

UNIQUE

(

DISTINCT UNIQUE

(

AVG MAX MIN SUM

ALL

Identifier

letter

17

letter digit underscore

Expression (Subset) p. 96

)

INTERVAL Field Qualifier

101

INTERVAL Field Qualifier YEAR

(y-precision) (4)

TO YEAR

MONTH

(precision) (2)

TO MONTH

(precision) (2)

TO DAY

(precision) (2)

TO HOUR

(precision) (2)

TO MINUTE

(precision) (2)

TO SECOND

DAY

HOUR

MINUTE

SECOND

FRACTION

TO FRACTION

(f-precision) (3)

Literal DATETIME DATETIME (

Numeric Datetime p. 102

)

DATETIME Field Qualifier 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 Field Qualifier p. 101

)

Numeric Interval

Numeric Interval

yyyy

mo dd space hh

: mi

: ss

. f

Literal Number

103

Literal Number

digit

.

+ -

.

digit

digit

E

+ -

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

Relational Operator < = >= !=

[

integer expression

]

105

Stored Procedure Language Statements

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 program. Doing so causes compile errors. To create a stored procedure from a 4GL program, do the following: 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 procedure having the name avg_price: select manu_code, unit_price, (avg_price(1) - unit_price) variance from stock where stock_num = 1

Such implicit references to stored procedures do not require the statement to be prepared.

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

106

CALL

CALL

Procedure Name p. 92

(

)

;

,

,

Argument

procedure variable

RETURNING

Argument

SPL Expression p. 112

parameter name = SELECT Statement (Subset) p. 82

CONTINUE

;

FOR WHILE FOREACH

, DEFINE

SQL Data Type (Subset) p. 93

variable name

GLOBAL

OL

REFERENCES

DEFAULT

BYTE

Default Value p. 107

DEFAULT NULL

TEXT

,

SQL Data Type (Subset) p. 93

variable name OL

BYTE

REFERENCES

TEXT LIKE

Table Name p. 92 Synonym Name p. 92 View Name p. 92 PROCEDURE

. column

;

107

EXIT

Default Value Constant Expression p. 97 NULL

EXIT

;

FOR WHILE FOREACH

, FOR

variable name

IN

(

left expression

right expression

TO

)

Statement Block p. 108

END FOR

; increment expression

STEP

, expression

=

left expression

TO

right expression

increment STEP expression

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

108

FOR

Statement Block

DEFINE Statement p. 106

ON EXCEPTION Statement p. 111

CALL Statement p. 106 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 Block

END

109

FOREACH

SELECT...INTO Statement p. 83

FOREACH

cursor name

Statement Block p. 108

END FOREACH

;

WITH HOLD FOR WITH HOLD

EXECUTE PROCEDURE

Procedure Name p. 92

(

)

, INTO

variable name

, variable name

IF

Condition p. 91

=

SPL Expression (Subset) p. 112

THEN

END IF

;

IF Statement List p. 110

ELIF

Condition p. 91

THEN

IF Statement List p. 110

ELSE

IF Statement List p. 110

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

110

IF

IF Statement List BEGIN

Statement Block p. 108

END

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

111

LET

, ,

,

variable name

LET

Procedure Name p. 92

=

SPL Expression p. 112

( called variable

=

;

)

, SPL Expression p. 112

Statement Block p. 108

ON EXCEPTION

, IN

SET

;

error number

(

) WITH RESUME

SQL error variable

,

ISAM error variable

, RAISE EXCEPTION

END EXCEPTION

error data variable

;

SQL error

, ISAM error , error text ;

RETURN

, SPL Expression p. 112 WITH RESUME

SYSTEM

" character expression " character variable

;

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

112

TRACE

TRACE

;

ON OFF PROCEDURE SPL Expression

WHILE

Condition p. 91

Statement Block p. 108

END WHILE

; SPL Expression SQL Expression p. 96

procedure variable name

|| + * /

(

SPL Expression

)

, Procedure Name p. 92

SPL 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 or SQLCA.SQLCODE

SQLCA.SQLERRD[1] through SQLCA.SQLERRD[6]

SQLCODE

SQLCA.SQLAWARN[1] through SQLCA.SQLAWARN[8]

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 statement 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 execution 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

database or when the number of items in the selectlist 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

? / ALIAS APPLICATION DEVICE BREAK IF CALL CLEANUP ALL CONTINUE DATABASE DISABLE ALL DUMP ALL GLOBALS ENABLE ALL EXIT FUNCTIONS GROW SOURCE COMMAND HELP ALL LET LIST BREAK TRACE NOBREAK ALL NOTRACE ALL PRINT READ RUN STEP INTO NOBREAK TIME DELAY SOURCE COMMAND

Shortest Form ? / al ap ap d b b if ca cl cl a co da di di all du du a du g en en all ex f g gs gc h ha le li li b li t nob nob all not not all p re ru s si sn ti ti s ti c

Command-Line Syntax

Command

Option

119

Shortest Form tr tr functions tu tu on tu of us va va all va globals vi vi l wh wr wr a wr b wr t

TRACE FUNCTIONS TURN ON OFF USE VARIABLE ALL GLOBALS VIEW LINE WHERE WRITE ALIAS BREAK TRACE

After setting a breakpoint (or tracepoint), the Output text region displays: reference checkpoint number type function

(2)

line number

module

break show_menu:91 [customer.4gl] scope function: show_menu checkpoint scope

CommandLine Syntax

To:

Type:

Escape Interrupt Redraw Screen Toggle Search for characters

! command CONTROL-D or Del key CONTROL-R CONTROL-P CONTROL-T

/ pattern ? pattern

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

120

ALIAS

/

pattern

?

pattern

ALIAS AL

alias name

=

command

Command List p. 127

*

break line

APPLICATION AP DEVICE

BREAK B

Checkpoint Initializaton p. 126

- count

IF boolean expression Command List p. 127

Checkpoint Target p. 127

These built-in operators can be used in a boolean expression: CURRENT DATE( ) DATETIME( ) DAY( )

CALL CA

function name

ENTEND( ) INTERVAL( ) MDY( ) MONTH( )

TODAY UNITS WEEKDAY( ) YEAR( )

)

( , argument

CLEANUP

121

CLEANUP CL ALL

CONTINUE CO

DATABASE DA

database

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

DISABLE DI

DUMP DU

Remote Database Engine

Format of database name

INFORMIX-OnLine Dynamic Server

database@servername or //servername/database

INFORMIX-SE

//servername/path/database

Checkpoint Identification p. 126

Scope List p. 128 Output Redirection p. 127

ENABLE EN

EXIT EX

Checkpoint Identification p. 126

Basics 4GL Forms Reports SQL 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

[characters] [character-character]

one or more unseparated characters characters within the range in ASCII collating sequence

zero or more characters

GROW G

integer



SOURCE COMMAND

HELP H

command ALL

LET LE

variable

Scope Qualification p. 128

LIST LI BREAK TRACE

= 4GL expression

NOBREAK

NOBREAK NOB

Checkpoint Identification p. 126

NOTRACE NOT

Checkpoint Identification p. 126

PRINT P

123

4GL expression OL PROGRAM

Output Redirection p. 127

= "program"

These built-in operators can be used within a 4GL expression: CURRENT DATE( ) DATETIME( ) DAY( )

READ RE

ENTEND( ) INTERVAL( ) MDY( ) MONTH( )

TODAY UNITS WEEKDAY( ) YEAR( )

filename .4db

RUN RU

argument

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

STEP S

number

INTO

NOBREAK

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

124

TIME DELAY

integer

TIME DELAY TI SOURCE COMMAND

TRACE TR

Checkpoint Initialization p. 126

FUNCTIONS Checkpoint Target p. 127

Command List p. 127

TURN TU

Output Redirection p. 127

AUTOTOGGLE ON

DISPLAYSTOPS

OFF

EXITSOURCE PRINTDELAY SOURCETRACE

USE US

,

=

pathname

VARIABLE VA

Scope List p. 128 Output Redirection p. 127 Scope Qualification p. 128

variable

VIEW

VIEW VI

125

function 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

. variable

Scope Qualification p. 128

function name

Type

Valid Entities

Triggered When

statement executable statements within 4GL functions †active variables variable function 4GL functions (including MAIN), 4GL reports, ESQL/C functions, C functions †You

Execution completes previous statement. Variable is assigned a different value. Function is called.

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 Environment Variable DBANSIWARN DBDATE DBDELIMITER DBEDIT DBFORMAT DBLANG DBMONEY DBPATH DBPRINT DBREMOTECMD DBSPACETEMP DBTEMP DBUPSPACE ENVIGNORE INFORMIXCONRETRY INFORMIXCONTIME INFORMIXDIR INFORMIXSERVER INFORMIXSHMBASE INFORMIXSTACKSIZE INFORMIXTERM ONCONFIG PSORT_DBTEMP PSORT_NPROCS SQLEXEC SQLRM SQLRMDIR

Restrictions

OnLine only OnLine only SE only

OnLine only OnLine only OnLine only OnLine only OnLine only SQL APIs only SQL APIs only

INFORMIX-4GL Reference Page D-8 D-9 D-11 D-11 D-14 D-18 D-21 D-23 D-26 D-27 D-28 D-29 D-29 D-30 D-30 D-31 D-32 D-33 D-33 D-34 D-34 D-36 D-36 D-37 D-38 D-38 D-39

Environment Variables

NLS Environment Variable

INFORMIX-4GL Reference Page

COLLCHAR DBAPICODE DBNLS LANG LC_COLLATE LC_CTYPE LC_MONETARY LC_NUMERIC

E-18 E-23 E-16 E-25 E-27 E-29 E-31 E-35

UNIX Environment Variable

INFORMIX-4GL Reference Page

PATH TERM TERMCAP TERMINFO

D-40 D-41 D-41 D-42

131

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 Accept

Interrupt Insert Delete Next Previous Help Quit

Purpose of Key

Default Keystroke

Selects the current menu option in a MENU statement; terminates input during CONSTRUCT, INPUT and INPUT ARRAY; terminates DISPLAY ARRAY. Represents the external interrupt signal; available when interrupts are deferred with the DEFER statement. Requests insertion of a new line during INPUT ARRAY, starting execution of a BEFORE INSERT block. Requests deletion of the current line during INPUT ARRAY, starting execution of a BEFORE DELETE block. Causes scrolling to the next page (group of lines) during DISPLAY ARRAY and INPUT ARRAY. Causes scrolling to the previous page (group of lines) during DISPLAY ARRAY and INPUT ARRAY. Starts the display of the specified HELP message from the current help file. Terminates the program unless DEFER QUIT is specified.

Escape

CONTROL-C

F1 F2

F3 F4 CONTROL-W CONTROL-\

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 modes. Deletes from the cursor to the end of the field. During text entry, moves the cursor left one position (nondestructive backspace). Cursor moves to next field; except in a WORDWRAP field, inserts a tab or skips to a tab depending on mode. Cursor moves to next field; except in a WORDWRAP field, inserts a newline or moves down one line depending on mode. During text entry, moves the cursor right one position.

None.

CONTROL-D CONTROL-H

(backspace) CONTROL-I or TAB CONTROL-J

(Linefeed) CONTROL-L

None. Moves highlight to next option left. None. Moves the highlight to the next option right. Moves the highlight to the next option right.

Default Key Assignments

135

Use in CONSTRUCT, INPUT, and Key Name

INPUT ARRAY

Use in MENU

CONTROL-M or RETURN

Completes entry of the current field. Cursor moves to next field if any; else same as Accept. Cursor moves to beginning of current field. Causes the screen to be redrawn.

Accepts the option that is currently highlighted.

CONTROL-N CONTROL-R CONTROL-X

Left Arrow Right Arrow Up Arrow

Down Arrow

None. Causes the screen to be redrawn. None. Same as Backspace. Same as CONTROL-L. Moves the highlight to the next option left.

Deletes the character under the cursor. Same as Backspace. Same as CONTROL-L. Moves to previous field; except in a WORDWRAP field moves up one line in field and in an INPUT ARRAY moves to the corresponding field in the previous row. 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 F2 F3 F4 F5 F6 F7 F8 F9

HELP STEP STEP INTO CONTINUE RUN LIST BREAK TRACE LIST DUMP EXIT

Basics 4GL Forms Reports SQL SQLCA Debugger Variables Keys

136

Default Key Assignments