Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #51 #52

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 78 additions & 45 deletions ocesql/ppout.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,12 @@ void ppoutputconnect(struct cb_exec_list *list) {
return;
}

void _ppoutputparam(char *varface, int type, int digits, int scale,
int iteration) {
static void _ppoutputparamheader(const char *mod, int type, int digits,
int scale) {
char buff[256];

memset(buff, 0, sizeof(buff));
com_sprintf(buff, sizeof(buff),
"OCESQL%5sCALL \"OCESQLSetSQLParams\" USING\n", " ");
com_sprintf(buff, sizeof(buff), "OCESQL%5sCALL \"%s\" USING\n", " ", mod);
fputs(buff, outfile);

memset(buff, 0, sizeof(buff));
Expand All @@ -422,6 +421,59 @@ void _ppoutputparam(char *varface, int type, int digits, int scale,
memset(buff, 0, sizeof(buff));
com_sprintf(buff, sizeof(buff), "OCESQL%10sBY VALUE %d\n", " ", scale);
fputs(buff, outfile);
}

static void _ppoutputparamfooter() {
char buff[256];
memset(buff, 0, sizeof(buff));

com_sprintf(buff, sizeof(buff), "OCESQL%5sEND-CALL\n", " ");
fputs(buff, outfile);
}

void __ppoutputparambyfield(const char *mod, struct cb_field *field, int type,
int digits, int scale, int iteration) {

char buff[256];

_ppoutputparamheader(mod, type, digits, scale);

memset(buff, 0, sizeof(buff));
com_sprintf(buff, sizeof(buff), "OCESQL%10sBY REFERENCE %s", " ",
field->sname);
fputs(buff, outfile);
struct cb_field *f = field->parent;

while (f) {
memset(buff, 0, sizeof(buff));
com_sprintf(buff, sizeof(buff), "\nOCESQL%10s OF %s", " ",
f->sname);
fputs(buff, outfile);
if (f->parent) {
memset(buff, 0, sizeof(buff));
com_sprintf(buff, sizeof(buff), "\n");
fputs(buff, outfile);
}
f = f->parent;
}

memset(buff, 0, sizeof(buff));
if (iteration > 0) {
com_sprintf(buff, sizeof(buff), "(1)\n", " ");
} else {
com_sprintf(buff, sizeof(buff), "\n");
}
fputs(buff, outfile);

_ppoutputparamfooter(type, digits, scale);
}

void __ppoutputparam(const char *mod, char *varface, int type, int digits,
int scale, int iteration) {
char buff[256];

_ppoutputparamheader(mod, type, digits, scale);

memset(buff, 0, sizeof(buff));
if (iteration > 0) {
com_sprintf(buff, sizeof(buff), "OCESQL%10sBY REFERENCE %s(1)\n", " ",
Expand All @@ -432,11 +484,18 @@ void _ppoutputparam(char *varface, int type, int digits, int scale,
}
fputs(buff, outfile);

memset(buff, 0, sizeof(buff));
_ppoutputparamfooter();
}

com_sprintf(buff, sizeof(buff), "OCESQL%5sEND-CALL\n", " ");
fputs(buff, outfile);
return;
void _ppoutputparambyfield(struct cb_field *field, int type, int digits,
int scale, int iteration) {
__ppoutputparambyfield("OCESQLSetSQLParams", field, type, digits, scale,
iteration);
}
void _ppoutputparam(char *varface, int type, int digits, int scale,
int iteration) {
__ppoutputparam("OCESQLSetSQLParams", varface, type, digits, scale,
iteration);
}

int ppoutputparam(struct cb_hostreference_list *host_list, int iteration) {
Expand Down Expand Up @@ -477,7 +536,7 @@ int ppoutputparam(struct cb_hostreference_list *host_list, int iteration) {
printerrormsg(f->sname, host_list->lineno, buff);
return count;
}
_ppoutputparam(f->sname, type, digits, scale, iteration);
_ppoutputparambyfield(f, type, digits, scale, iteration);
count++;
f = f->sister;
}
Expand All @@ -489,41 +548,16 @@ int ppoutputparam(struct cb_hostreference_list *host_list, int iteration) {
return count;
}

void ppoutputresparambyfield(struct cb_field *field, int type, int digits,
int scale, int iteration) {
__ppoutputparambyfield("OCESQLSetResultParams", field, type, digits, scale,
iteration);
}

void ppoutputresparam(char *varface, int type, int digits, int scale,
int iteration) {
char buff[256];

memset(buff, 0, sizeof(buff));
com_sprintf(buff, sizeof(buff),
"OCESQL%5sCALL \"OCESQLSetResultParams\" USING\n", " ");
fputs(buff, outfile);

memset(buff, 0, sizeof(buff));
com_sprintf(buff, sizeof(buff), "OCESQL%10sBY VALUE %d\n", " ", type);
fputs(buff, outfile);

memset(buff, 0, sizeof(buff));
com_sprintf(buff, sizeof(buff), "OCESQL%10sBY VALUE %d\n", " ", digits);
fputs(buff, outfile);

memset(buff, 0, sizeof(buff));
com_sprintf(buff, sizeof(buff), "OCESQL%10sBY VALUE %d\n", " ", scale);
fputs(buff, outfile);
memset(buff, 0, sizeof(buff));
if (iteration > 0) {
com_sprintf(buff, sizeof(buff), "OCESQL%10sBY REFERENCE %s(1)\n", " ",
varface);
} else {
com_sprintf(buff, sizeof(buff), "OCESQL%10sBY REFERENCE %s\n", " ",
varface);
}
fputs(buff, outfile);

memset(buff, 0, sizeof(buff));

com_sprintf(buff, sizeof(buff), "OCESQL%5sEND-CALL\n", " ");
fputs(buff, outfile);
return;
__ppoutputparam("OCESQLSetResultParams", varface, type, digits, scale,
iteration);
}

void ppoutputresgroup(struct cb_field *cf, int lineno, int iteration) {
Expand All @@ -546,7 +580,7 @@ void ppoutputresgroup(struct cb_field *cf, int lineno, int iteration) {
if (type == HVARTYPE_GROUP) {
ppoutputresgroup(cf->children, lineno, iteration);
} else {
ppoutputresparam(cf->sname, type, digits, scale, iteration);
ppoutputresparambyfield(cf, type, digits, scale, iteration);
}

if (cf->sister != NULL) {
Expand Down Expand Up @@ -1661,8 +1695,7 @@ void ppbuff(struct cb_exec_list *list) {
printerrormsg(child->sname, wk_res_host->lineno, buff);
return;
}
ppoutputresparam(child->sname, var_type, var_len, var_scale,
iteration);
ppoutputresparambyfield(child, var_type, var_len, var_scale, iteration);
child = child->sister;
reshostreferenceCount++;
}
Expand Down