Share this page

# lrd_assign_literal

Assigns a literal string to a variable via its descriptor.

    LRDRET lrd_assign_literal( LRD_VAR_DESC *mptVarDesc, char *mpcValStr, 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.
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_literal function assigns a literal string value, enclosed by quotation marks, to a variable (scalar or array) 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). The length of the string is determined by (sizeof(string) -1).

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.

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_literal assigns values to the host variable F_D1. The values assigned to the variable are not null-terminated—they contain null characters. The lrd_bind_placeholder function binds the host variable to the placeholders.

     /* 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_literal(&F_D1, "Jim\x00\x00\x00", "", 0, 0);

    lrd_assign_literal(&F_D1, "Bob\x00\x00\x00", "", 1, 0);

    lrd_assign_literal(&F_D1, "Mike\x00\x00\x00", "", 2, 0);

    lrd_bind_placeholder(Csr2, "F", &F_D1, 0, 0);

    lrd_assign(&L_D2, "Smith", "", 0, 0);

    lrd_assign(&L_D2, "Jones", "", 1, 0);

    lrd_assign(&L_D2, "Anderson", "", 2, 0);

    lrd_bind_placeholder(Csr2, "L", &L_D2, 0, 0);

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