3. Embedded SQL for COBOL : COBOL Data Items and Data Types : Data Types
 
Share this page                  
Data Types
Embedded SQL supports a subset of the COBOL data types. The following table maps the COBOL data types to their corresponding Ingres types. Note that the COBOL data type is determined by its category, picture, and usage.
Category
COBOL Type Picture
Usage
Ingres Type
ALPHABETIC
any
DISPLAY
character
ALPHANUMERIC
any
DISPLAY
character
ALPHANUMERIC
EDITED
any
DISPLAY
Character
NUMERIC
9(p) where p <=10
COMP DISPLAY
integer
NUMERIC
9(p)V9(s) where p+s <=9
COMP DISPLAY
float
NUMERIC
9(p) where p <=10
COMP-3
Integer
NUMERIC
9(p) where p >10
COMP-3
decimal
NUMERIC
9(p)V9(s)
COMP-3
decimal
NUMERIC
 
INDEX
integer
NUMERIC EDITED
any
DISPLAY
integer float
NUMERIC
 
COMP-3
Decimal
VMS
NUMERIC
PACKED-DECIMAL
COMP-1
decimal
VMS
NUMERIC
 
 
float
VMS
NUMERIC
 
COMP-2
float
Because COBOL supports the packed decimal data type, the Ingres decimal type is mapped to it. In COBOL, the decimal data type is COMP3. For example, the COBOL packed decimal declarations (where Pr = precision and Sc = scale):
01 PACK1 PIC S9(Pr-Sc)V9(Sc) USAGE COMP-3.
01 PACK2 PIC S9(Pr)   USAGE COMP-3.
correspond to the Ingres decimal types:
DECIMAL (Pr,Sc)
DECIMAL (Pr,0)
Note that Ingres precision includes scale, since it includes the total number of digits, and Ingres scale is the number of digits to the right of the decimal point.
The sign (S) is optional on a COBOL declaration and is ignored by the preprocessor. However, decimal values are always stored as signed by Ingres.
Note:  You should always retrieve Ingres decimal data into a signed decimal variable.
COMP is an abbreviation for COMPUTATIONAL. You can use either form. Note that POINTER data items are not supported. The following sections describe the various data categories and the manner in which embedded SQL interacts with them.
Character strings containing embedded single quotes are legal in SQL.
Example: Embedded single quotes usage
mary's
User variables may contain embedded single quotes and need no special handling unless the variable represents the entire search condition of a where clause:
where :variable
In this case you must escape the single quote by reconstructing the :variable string so that any embedded single quotes are modified to double single quotes, as in:
mary''s
Otherwise, a runtime error will occur. For more information on escaping single quotes, see String Literals (see page String Literals) in this chapter.