Fchg32 is the Swiss Army knife of Tuxedo FML32
FML32
is Oracle Tuxedo buffer type similar to std::multimap
in C++ or multidict
in Python where the key might occur more than once in the container. Fchg32
is the function for changing a value for a specific key and occurence. But carefully reading the documentation reveals more interesting details.
First, if there are only two occurances and you try to change the value of the fifth occurance, a third and forth occurance with the default value (0
for numeric fields) will be added:
#include <atmi.h>
#include <fml32.h>
#include <tpadm.h>
int main() {
long value;
FBFR32 *fbfr = (FBFR32 *)tpalloc((char *)"FML32", NULL, 1024);
value = 1;
Fchg32(fbfr, TA_MORE, 0, (char *)&value, 0);
value = 2;
Fchg32(fbfr, TA_MORE, 1, (char *)&value, 0);
value = 5;
Fchg32(fbfr, TA_MORE, 4, (char *)&value, 0);
Fprint32(fbfr);
return 0;
}
$ buildclient -o demo -f demo.c
[oracle@15c365dcb562 c]$ ./demo
TA_MORE 1
TA_MORE 2
TA_MORE 0
TA_MORE 0
TA_MORE 5
Second, Fchg32
will behave like Fadd32
and add new occurances when the occurence -1
is specified:
#include <atmi.h>
#include <fml32.h>
#include <tpadm.h>
int main() {
long value;
FBFR32 *fbfr = (FBFR32 *)tpalloc((char *)"FML32", NULL, 1024);
value = 1;
Fchg32(fbfr, TA_MORE, -1, (char *)&value, 0);
value = 2;
Fchg32(fbfr, TA_MORE, -1, (char *)&value, 0);
value = 3;
Fchg32(fbfr, TA_MORE, -1, (char *)&value, 0);
Fprint32(fbfr);
return 0;
}
$ buildclient -o demo -f demo.c
[oracle@15c365dcb562 c]$ ./demo
TA_MORE 1
TA_MORE 2
TA_MORE 3
Third, Fchg32
will behave like Fdel32
and delete existing fields when the value NULL
is specified:
#include <atmi.h>
#include <fml32.h>
#include <tpadm.h>
int main() {
long value;
FBFR32 *fbfr = (FBFR32 *)tpalloc((char *)"FML32", NULL, 1024);
value = 1;
Fchg32(fbfr, TA_MORE, -1, (char *)&value, 0);
value = 2;
Fchg32(fbfr, TA_MORE, -1, (char *)&value, 0);
value = 3;
Fchg32(fbfr, TA_MORE, -1, (char *)&value, 0);
Fchg32(fbfr, TA_MORE, 0, NULL, 0);
Fchg32(fbfr, TA_MORE, 0, NULL, 0);
Fprint32(fbfr);
return 0;
}
$ buildclient -o demo -f demo.c
[oracle@15c365dcb562 c]$ ./demo
TA_MORE 3
Fchg32
is the Swiss Army knife of FML32
API functions.