7. Embedded SQL for Pascal : Pascal Variables and Data Types : Embedded SQL/Pascal Declarations : Character Data Types
 
Share this page                  
Character Data Types
Three Pascal data types are compatible with Ingres string objects: char, packed array of char, and varying of char. Note that literal string constants are of type packed array of char. Embedded SQL allows only regular Pascal string literals: sequences of printing characters enclosed in single quotes. The VMS Pascal extensions of parenthesized string constructors and of non-printing characters represented by their ASCII values in parentheses are not allowed.
The char data type does have some restrictions. Because of the mechanism used to pass string-valued arguments to the Embedded SQL runtime library, you cannot use a member of a packed array of char or varying of char to interact with Ingres. Also, a plain array of char (that is, not packed or varying) is not compatible with Ingres string objects; an element of such an array, however, is a char and as such is compatible.
For example, given the following legal declarations:
exec sql begin declare section;
type
    Alpha = 'a'..'z';              {1 character}
    Packed_6 = packed array[1..6]
               of Char;            {6-char string}
    Vary_6 = varying[6] of Alpha;  {6-char string}
    Array_6 = array[1..6]
               of Char;            {1-dimensional array}


var
    letter: Alpha; {1 character}
    p_str_arr: array[1..5]
              of Packed_6;  {Array of strings}
    chr_arr: array[1..6]
of Char;            {1-dimensional array}
    two_arr: array[1..5]
        of Array_6;         {2-dimensional array of char}
    v_string : Vary_6;             {String}
exec sql end declare section;
these usages are legal:
exec frs message letter;          {A char is a string}
exec frs message chr_arr[3];      {A char is a string}
exec frs message two_arr[2][5];   {A char is a string}
exec frs message v_string;  {A varying array is a string}
exec frs message p_str_arr[2];
                         {A packed array is a string}
but these usages are illegal:
exec frs message
            chr_arr;    {An array of chars is not a string}
exec frs message
            v_string[2];      {Cannot index a varying array}
exec frs message
            p_str_arr[2][3];  {Cannot index a packed array}