Skip to content

Commit ada2ad5

Browse files
fix: input host variables with parent name
1 parent 4638a37 commit ada2ad5

File tree

1 file changed

+76
-42
lines changed

1 file changed

+76
-42
lines changed

ocesql/ppout.c

Lines changed: 76 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,12 @@ void ppoutputconnect(struct cb_exec_list *list) {
402402
return;
403403
}
404404

405-
void _ppoutputparam(char *varface, int type, int digits, int scale,
406-
int iteration) {
405+
static void _ppoutputparamheader(const char *mod, int type, int digits,
406+
int scale) {
407407
char buff[256];
408408

409409
memset(buff, 0, sizeof(buff));
410-
com_sprintf(buff, sizeof(buff),
411-
"OCESQL%5sCALL \"OCESQLSetSQLParams\" USING\n", " ");
410+
com_sprintf(buff, sizeof(buff), "OCESQL%5sCALL \"%s\" USING\n", " ", mod);
412411
fputs(buff, outfile);
413412

414413
memset(buff, 0, sizeof(buff));
@@ -422,6 +421,59 @@ void _ppoutputparam(char *varface, int type, int digits, int scale,
422421
memset(buff, 0, sizeof(buff));
423422
com_sprintf(buff, sizeof(buff), "OCESQL%10sBY VALUE %d\n", " ", scale);
424423
fputs(buff, outfile);
424+
}
425+
426+
static void _ppoutputparamfooter() {
427+
char buff[256];
428+
memset(buff, 0, sizeof(buff));
429+
430+
com_sprintf(buff, sizeof(buff), "OCESQL%5sEND-CALL\n", " ");
431+
fputs(buff, outfile);
432+
}
433+
434+
void __ppoutputparambyfield(const char *mod, struct cb_field *field, int type,
435+
int digits, int scale, int iteration) {
436+
437+
char buff[256];
438+
439+
_ppoutputparamheader(mod, type, digits, scale);
440+
441+
memset(buff, 0, sizeof(buff));
442+
com_sprintf(buff, sizeof(buff), "OCESQL%10sBY REFERENCE %s", " ",
443+
field->sname);
444+
fputs(buff, outfile);
445+
struct cb_field *f = field->parent;
446+
447+
while (f) {
448+
memset(buff, 0, sizeof(buff));
449+
com_sprintf(buff, sizeof(buff), "\nOCESQL%10s OF %s", " ",
450+
f->sname);
451+
fputs(buff, outfile);
452+
if (f->parent) {
453+
memset(buff, 0, sizeof(buff));
454+
com_sprintf(buff, sizeof(buff), "\n");
455+
fputs(buff, outfile);
456+
}
457+
f = f->parent;
458+
}
459+
460+
memset(buff, 0, sizeof(buff));
461+
if (iteration > 0) {
462+
com_sprintf(buff, sizeof(buff), "(1)\n", " ");
463+
} else {
464+
com_sprintf(buff, sizeof(buff), "\n");
465+
}
466+
fputs(buff, outfile);
467+
468+
_ppoutputparamfooter(type, digits, scale);
469+
}
470+
471+
void __ppoutputparam(const char *mod, char *varface, int type, int digits,
472+
int scale, int iteration) {
473+
char buff[256];
474+
475+
_ppoutputparamheader(mod, type, digits, scale);
476+
425477
memset(buff, 0, sizeof(buff));
426478
if (iteration > 0) {
427479
com_sprintf(buff, sizeof(buff), "OCESQL%10sBY REFERENCE %s(1)\n", " ",
@@ -432,11 +484,18 @@ void _ppoutputparam(char *varface, int type, int digits, int scale,
432484
}
433485
fputs(buff, outfile);
434486

435-
memset(buff, 0, sizeof(buff));
487+
_ppoutputparamfooter();
488+
}
436489

437-
com_sprintf(buff, sizeof(buff), "OCESQL%5sEND-CALL\n", " ");
438-
fputs(buff, outfile);
439-
return;
490+
void _ppoutputparambyfield(struct cb_field *field, int type, int digits,
491+
int scale, int iteration) {
492+
__ppoutputparambyfield("OCESQLSetSQLParams", field, type, digits, scale,
493+
iteration);
494+
}
495+
void _ppoutputparam(char *varface, int type, int digits, int scale,
496+
int iteration) {
497+
__ppoutputparam("OCESQLSetSQLParams", varface, type, digits, scale,
498+
iteration);
440499
}
441500

442501
int ppoutputparam(struct cb_hostreference_list *host_list, int iteration) {
@@ -477,7 +536,7 @@ int ppoutputparam(struct cb_hostreference_list *host_list, int iteration) {
477536
printerrormsg(f->sname, host_list->lineno, buff);
478537
return count;
479538
}
480-
_ppoutputparam(f->sname, type, digits, scale, iteration);
539+
_ppoutputparambyfield(f, type, digits, scale, iteration);
481540
count++;
482541
f = f->sister;
483542
}
@@ -489,41 +548,16 @@ int ppoutputparam(struct cb_hostreference_list *host_list, int iteration) {
489548
return count;
490549
}
491550

551+
void ppoutputresparambyfield(struct cb_field *field, int type, int digits,
552+
int scale, int iteration) {
553+
__ppoutputparambyfield("OCESQLSetResultParams", field, type, digits, scale,
554+
iteration);
555+
}
556+
492557
void ppoutputresparam(char *varface, int type, int digits, int scale,
493558
int iteration) {
494-
char buff[256];
495-
496-
memset(buff, 0, sizeof(buff));
497-
com_sprintf(buff, sizeof(buff),
498-
"OCESQL%5sCALL \"OCESQLSetResultParams\" USING\n", " ");
499-
fputs(buff, outfile);
500-
501-
memset(buff, 0, sizeof(buff));
502-
com_sprintf(buff, sizeof(buff), "OCESQL%10sBY VALUE %d\n", " ", type);
503-
fputs(buff, outfile);
504-
505-
memset(buff, 0, sizeof(buff));
506-
com_sprintf(buff, sizeof(buff), "OCESQL%10sBY VALUE %d\n", " ", digits);
507-
fputs(buff, outfile);
508-
509-
memset(buff, 0, sizeof(buff));
510-
com_sprintf(buff, sizeof(buff), "OCESQL%10sBY VALUE %d\n", " ", scale);
511-
fputs(buff, outfile);
512-
memset(buff, 0, sizeof(buff));
513-
if (iteration > 0) {
514-
com_sprintf(buff, sizeof(buff), "OCESQL%10sBY REFERENCE %s(1)\n", " ",
515-
varface);
516-
} else {
517-
com_sprintf(buff, sizeof(buff), "OCESQL%10sBY REFERENCE %s\n", " ",
518-
varface);
519-
}
520-
fputs(buff, outfile);
521-
522-
memset(buff, 0, sizeof(buff));
523-
524-
com_sprintf(buff, sizeof(buff), "OCESQL%5sEND-CALL\n", " ");
525-
fputs(buff, outfile);
526-
return;
559+
__ppoutputparam("OCESQLSetResultParams", varface, type, digits, scale,
560+
iteration);
527561
}
528562

529563
void ppoutputresgroup(struct cb_field *cf, int lineno, int iteration) {

0 commit comments

Comments
 (0)