The invmuldbl() function
The invmuldbl() function multiplies an interval value by a numeric value.
Syntax
mint invmuldbl(iv, num, ov)
intrvl_t *iv;
double num;
intrvl_t *ov;
- iv
- A pointer to the interval variable to multiply.
- num
- The numeric double value.
- ov
- A pointer to the interval variable with a valid qualifier.
Usage
The invmuldbl() function multiplies the interval value in iv by num and stores the result in ov. The value in num can be either positive or negative.
Both the input and output qualifiers must belong to the same interval class: either the year to month class or the day to fraction(5) class. If the qualifier for ov is different from the qualifier for iv (but of the same class), the invmuldbl() function extends the result (as the invextend() function defines).
Return codes
- 0
- The multiplication was successful.
- <0
- The multiplication failed.
- -1200
- A numeric value is too large (in magnitude).
- -1201
- A numeric value is too small (in magnitude).
- -1266
- An interval value is incompatible with the operation.
- -1268
- A parameter contains an invalid interval qualifier.
Example
The demo directory
contains this sample program in the file invmuldbl.ec.
The example illustrates how to multiply an interval value by
a numeric value. The second multiplication illustrates the result
of interval multiplication when the input and output qualifiers
are different.
/*
* invmuldbl.ec *
The following program multiplies an INTERVAL type variable by a numeric value
and stores the result in an INTERVAL variable. The operation is done twice,
using INTERVALs with different qualifiers to store the result.
*/
#include <stdio.h>
EXEC SQL include datetime;
main()
{
char out_str[16];
EXEC SQL BEGIN DECLARE SECTION;
interval hour to minute hrtomin1;
interval hour to minute hrtomin2;
interval day to second daytosec;
EXEC SQL END DECLARE SECTION;
printf("INVMULDBL Sample ESQL Program running.\n\n");
/* input is 25 hours, and 49 minutes */
printf("Interval (hour to minute) = 25:49\n");
incvasc("25:49", &hrtomin1);
printf("Multiplier (double) = 3.0\n");
printf("-------------------------------------------------------\n");
/* Convert the internal format to ascii for displaying */
invmuldbl(&hrtomin1, (double) 3.0, &hrtomin2);
intoasc(&hrtomin2, out_str);
printf("Product #1 (hour to minute) = '%s'\n", out_str);
/* Convert the internal format to ascii for displaying */
invmuldbl(&hrtomin1, (double) 3.0, &daytosec);
intoasc(&daytosec, out_str);
printf("Product #2 (day to second) = '%s'\n", out_str);
printf("\nINVMULDBL Sample Program over.\n\n");
}
Output
INVMULDBL Sample ESQL Program running.
Interval (hour to minute) = 25:49
Multiplier (double) = 3.0
---------------------------------------------
Product #1 (hour to minute) = ' 77:27'
Product #2 (day to second) = ' 3 05:27:00'
INVMULDBL Sample Program over.