2. Writing Scripts and Procedures : Procedures : 3GL Procedures : 3GL Parameters
 
Share this page                  
3GL Parameters
OpenROAD lets you pass simple variables to a 3GL procedure. You can also pass objects and arrays as described in the Language Reference Guide online help and in Using 3GL in Your Application (see Using 3GL in Your Application). When you pass values to a 3GL procedure, the data type of the values must match the data types of the parameters receiving them in the procedure.
The following table lists the 4GL simple data types and describes their corresponding 3GL data type declarations:
4GL Data Type
Host Variable Declaration
Char
Fixed-length, null-terminated character string. The size is determined by field size or declared variable length. Data entered into the field is padded with blank characters up to its full declared length before being passed to the 3GL procedure.
Varchar
Variable-length, null-terminated character string. Unlike char type, varchar variables are not extended with blank characters before being passed to the 3GL procedure.
date
Fixed-length, 25-byte, null-terminated character string
money
Double
float, f
Double
integer
Long, 4-byte integer
smallint
Integer, 4-byte integer
You can use the byref option with any variable that you pass to a 3GL procedure, regardless of the variable's data type.
You cannot pass a char or varchar variable that contains an embedded zero byte (hexadecimal'00') to a 3GL procedure. No runtime error occurs, but a truncated version of the 4GL variable may be passed.
When a 4GL date variable passes to a 3GL procedure by name, or when the return type of a 3GL procedure is date, 4GL receives it back from the 3GL procedure as a 25-byte string and must then convert it to the internal date format. The date must be valid before the conversion can succeed.
Passing a 4GL variable containing a null value to a 3GL procedure causes a runtime error. Use the ifnull function and is null comparison operator to pass nullable types between 3GL and 4GL, for example:
ifnull (v1, v2)
This reference returns the value of v1 if v1 is not null; otherwise, if v1 is null, it returns the value of v2. The variables v1 and v2 must be the same data type.
If an impossible value exists for the argument, use the impossible value to indicate a null:
callproc empcalc (ifnull (age, -1));
If no impossible value exists for the argument, pass a separate indicator variable to indicate a null argument:
null_indicator = 0;
if (age is null) then
     null_indicator = -1;
endif;
callproc empcalc (age, null_indicator);