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.
Because COBOL supports the packed decimal data type, the Ingres decimal type is mapped to it. In COBOL, the decimal data type is COMP‑3. 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 in this chapter.