Was this helpful?
Data Types for Simple Local Variables and Hidden Columns
A data type specifies the way data is stored in a database table. Examples of data types are integer, char, date, and money. In a declaration statement, you declare a variable or hidden column you are planning to use in your 4GL specification by stating its name and data type. The 4GL syntax for a simple local variable or hidden column declaration is as follows:
localcomponent = typedeclaration [ ( length | p,s ) ] 
        [ with null | not null ]
In the syntax above, localcomponent is the simple local variable or hidden column, typedeclaration is an Ingres data type name, length is the length of a character data type, and p,s is the precision and scale for a decimal data type. The length, precision, and scale are all integers. The format for declaring data types in 4GL is the same as that used by the Ingres DBMS in create statements.
4GL does not support the Ingres data types long varchar, long bit, byte, byte varying, and long byte. You cannot define a local variable or hidden column as one of these types. However, if you select a column from the database into an appropriate data type, 4GL coerces and truncates the data. For example, you can select a column of type long varchar from the database into a char or varchar variable.
You can also manipulate long varchars by storing each segment of the long varchar into a varchar element of a 4GL array variable.
4GL recognizes a number of data type names and synonyms. The recommended type names (ANSI standard for character and numeric types) are shown in the following table:
Type
Length
(bytes)
Description
Cn
1 <= n <= x
Fixed-length character string, printable characters only. Synonym: c(n). 'x' represents the lesser of the maximum configured row size and 32,000.
char(n)
1 <= n <= x
Fixed-length character string, all characters. Synonym: character(n). 'x' represents the lesser of the maximum configured row size and 32,000.
text(n)
1 <= n <= x
Variable-length character string, all characters except NULL. Synonym: vchar(n). 'x' represents the lesser of the maximum configured row size and 32,000.
varchar(n)
1 <= n <= x
Variable-length character string, all characters; 'x' represents the lesser of the maximum configured row size and 32,000.
float(n)
4 if 0 <= n <= 7
Floating-point number. Synonym: f4
 
8 if 8 <= n <= 53
Floating-point number. Synonym: f8
decimal(p,s)
Depends on precision and scale
If precision and scale are not specified, the defaults are (5, 0)
Fixed‑point number.
Synonyms: dec(p,s), numeric(p,s)
integer1
1
Integer number.
Synonyms: i1
Smallint
2
Integer number.
Synonyms: i2, integer2.
Integer
4
Integer number.
Synonyms: i4, integer4, int.
Date
12
Abstract.
Money
8
Abstract.
These general definitions apply to the data types:
An integer is a whole number.
A floating-point value consists of an integer, a decimal point, a fraction, and optionally an exponent.
A fixed-point decimal value consists of an integer, a decimal point, and a fraction. Decimal numbers that contain an exponent or that are longer than 31 digits must be treated as floating-point values.
A character value is a sequence of characters.
The abstract data types date and money allow you to handle time and monetary units with the facility of the simpler data types.
In SQL, nullable versions of each simple data type are allowed. By default, a type in 4GL is nullable unless the not null clause is used. Even so, it is advisable to use the with null clause to clearly document this. For example, to declare the type money nullable, use the format money with null.
For a complete description of each data type, see your query language reference guides. The Using Character-based Querying and Reporting Tools User Guide provides more information on declaring data types for variables.
Note for Enterprise Access Products Users
4GL does not support non-OpenSQL data types in database statements in 4GL (select, delete, insert, update). For Enterprise Access products (formerly Gateways), the limits for character data types are as follows:
char: <= 254;
varchar: <= 4096
Last modified date: 01/30/2023