Share this page

# lrd_assign_ext

Assigns a storage area value with an explicit length to a variable via its descriptor.

    LRDRET lrd_assign_ext( LRD_VAR_DESC *mptVarDesc, char *mpcValStr, long mliValStrLen, char *mpszValStrFmt, unsigned long muliIndex, long mliOffset );

mptVarDesc | A pointer to the descriptor of a variable to which the value is being assigned.
mpcValStr | A pointer to the input value string, or NULL. If the value is not NULL, the string can be parameterized
mliValStrLen | The length of the string.
mpszValStrFmt | The input value format: LRD_VAL_STR_FMT_ type where type can be DFLT or RAW.
muliIndex | The zero-based index of the array element to set (zero for non-array variables).
mliOffset | The offset within the host variable indicating the location at which to assign a value to the variable. For example, if the variable has a prefix that you want to retain, set the offset to a value greater than the size of the prefix.

The lrd_assign_ext assigns a storage area value with an explicit length to a variable via its descriptor. If necessary, the value is converted to the variable's data type and length. The value can contain embedded null characters ('\0'). You can also specify a NULL value using NULL or 0 (without quotation marks).

When the placeholder variable is an array, this function assigns a value to a single element of the array. This function must precede its corresponding lrd_bind_placeholder.

Note that this function is not recorded during a database session—you must insert it manually. It is useful for applications using bitmaps or other applications where the length of the value is not known, and the values contain null characters.

To use the values from a storage area such as an array, you:

1. Modify the function name from lrd_assign or lrd_assign_literal, to lrd_assign_ext.
2. Replace the string with a variable containing the values.
3. Specify a length for the string.

For more details refer to the Function Header File lrd.h in the include directory.

## Return Values

See LRD Return Values.

## Parameterization

The following argument can be parameterized using standard parameterization: mpcValStr

## Example

In the following example, lrd_assign_ext assigns values to the host variable F_D1 from an array called name. The lrd_bind_placeholder function binds the host variable to the placeholders F and L. The name array was defined at the beginning of the section as

        char <span style="font-style: italic;">name</span>[15].

The actual recorded code was:

     /* Insert employee data into the employee table. */
    lrd_stmt(Csr2, "insert into employees (emp_firstname,emp_lastname)" "values(:F,:L)", -1, 1 /*Deferred*/, 1 /*Dflt Ora Ver*/, 0);
    lrd_assign(&F_D1, "Jim", "", 0, 0);
    lrd_assign(&F_D1, "Bob", "", 1, 0);
    lrd_assign(&F_D1, "Mike", "", 2, 0);
    lrd_bind_placeholder(Csr2, "F", &F_D1, 0, 0);
    If the names contain null characters and are variable length, you modify the existing code in the following way:
    lrd_assign_ext(&F_D1, name[0], 5, "", 0, 0);
    lrd_assign_ext(&F_D1, name[1], 6, "", 1, 0);
    lrd_assign_ext(&F_D1, name[2], 6, "", 2, 0);
    lrd_bind_placeholder(Csr2, "F", &F_D1, 0, 0);

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: