lr_param_increment
Increments the value of a numerical parameter.
int lr_param_increment( char *destination_param, char *source_param );
| Alphabetical Listing - C Language Utility Functions |
Arguments
| Name | Comments |
|---|---|
| destination_param | The name of the parameter to store the incremented parameter |
| source_param | The name of the parameter whose value is incremented |
The lr_param_increment function retrieves the value of source_param, increments its value by one, and stores the incremented value as a null terminated string in destination_param.
This function is useful only in protocols that have a numerical parameter type. For protocols that have only string parameters, increment with C functions. For example:
i = atoi(lr_eval_string("{modification_num}"));
sprintf(buf, "%d", i+1);
lr_save_string(buf, "next_modnum");
For protocols that have a numerical parameter, lr_param_increment can be used:
lr_param_increment("next_modnum", "{modification_num}");source_param must be initialized with an integer value prior to calling lr_param_increment. source_param's value should include only single-byte digit characters with an optional sign or leading zeros.
When destination_param exists, its value is overwritten. When it doesn't exist, the parameter is created dynamically.
The value of source_param is restricted to the maximum value of a long integer minus 1.
Return Values
This function returns the following values:
| Enum | Value | Result |
|---|---|---|
| LR_PARAM_INC_OK | 0 | Success |
| LR_PARAM_INC_ERR_SAVE_FAILED | -1 | The save operation to the destination parameter failed. |
| LR_PARAM_INC_ERR_MBCS_IN_SRC | -2 | The source parameter includes multibyte characters, which indicates that it is not a pure numeric parameter. |
| LR_PARAM_INC_ERR_SRC_NOT_NUM | -3 | The source parameter includes singlebyte characters that are not digits, or the source parameter does not exist. |
| LR_PARAM_INC_ERR_EVAL_FAILED | -4 | The evaluation operation of the source parameter failed. |
Parameterization
Standard parameterization is not available for this function.
Example
The following code snippet illustrates lr_param_increment being used to increment the value of a parameter modification_num, and storing the incremented value as a new parameter, next_modnum.
This new parameter is assigned to the ":1" placeholder within an Oracle statement using lrd_assign(). The statement is then executed using the lrd_ora8_exec function.
/* Get value of modification_num from Oracle database */
lrd_ora8_save_col(OraStm142, 9, 1, 0, "modification_num");
/* modification_num = "194128" */
lrd_ora8_fetch(OraStm142, -1, 408, &uliFetchedRows, PrintRow52, 2, 0, 1);
/* Increment modification_num and store it as "next_modnum" */
lr_param_increment("next_modnum", "{modification_num}");
/* next_modnum was "194129" during recording. */
lrd_ora8_stmt(OraStm143, "\nUPDATE S_SSA_ID SET\n "
"NEXT_SUFFIX = 'ABCDE',\n MODIFICATION_NUM = :1\n "
" WHERE\n MODIFICATION_NUM = :2\n", 1, 0, 0);
/* Assign the new incremented value of next_modnumto the statement */
lrd_assign(&P1D1062, "{next_modnum}", 0, 0, 0);
lrd_ora8_bind_placeholder(OraStm143, &OraBnd496, "1", &P1D1062,
LRD_BIND_BY_POS, 0, 0);
lrd_assign(&P2D1063, "{modification_num}", 0, 0, 0);
lrd_ora8_bind_placeholder(OraStm143, &OraBnd497, "2", &P2D1063,
LRD_BIND_BY_POS, 0, 0);
lrd_ora8_exec(OraSvc6, OraStm143, 1, 0, &uliRowsProcessed, 0, 0, 0, 0, 0);

