5. Embedded SQL for Ada : Ada Variables and Data Types : Embedded SQL/Ada Declarations : Formal Parameter Declarations
 
Share this page                  
Formal Parameter Declarations
An Embedded SQL/Ada formal parameter declaration has the following syntax:
identifier {, identifier} :
              [in | out | in out
              type_name
              [:= default_value ]
              [;]
Like other Embedded SQL declarations, the formal parameter declaration must occur inside a declaration section. In a subprogram specification, its syntax is:
procedure name
              exec sql begin declare section;
                            ( parameter_declaration {; parameter_declaration} )
              exec sql end declare section;
                            is
                            ...
or:
function name
              exec sql begin declare section;
                            ( parameter_declaration {; parameter_declaration} )
              exec sql end declare section;
                            return type_name is
                            ...
Syntax Notes:
The Embedded SQL preprocessor processes only the formal parameter declarations in a subprogram specification.
If you specify the in mode alone, the declared parameters are considered constants and cannot be targets of Ingres assignments.
If you do not specify a mode, the default in mode is used and the declared parameters are considered constants.
The type_name must be either an Embedded SQL/Ada type or a type name already declared to Embedded SQL.
The preprocessor does not parse the default_value. Consequently, the preprocessor accepts any default value, even if it can later cause a Ada compiler error. For example, Embedded SQL accepts both of the following parameter defaults, even though only the first is legal in Ada:
procedure Load_Table
    exec sql begin declare section;
        (clear_it: in Boolean := TRUE;
         is_error: out Boolean := "FALSE")
    exec sql end declare section;
    is
    ...
You must not use a single quote in a default value to specify an Ada attribute. Embedded SQL treats it as the beginning of a string literal and generates an error.
You must use the semicolon with all parameter declarations except the last.
As with all other Embedded SQL/Ada declarations, formal parameter declarations are global from the point of declaration to the end of the file. For more information, see The Scope of Variables (see page The Scope of Variables) in this chapter.