- while (isc_dsql_fetch(status, &stmth, out_sqlda->version, out_sqlda) !=
- 100L) {
- /* check if an error occurred */
- if (status[0] & status[1]) {
- isc_interprete(buffer, &statusp);
- *errmsg =
- string_sprintf("Interbase fetch() failed: %s", buffer);
- isc_dsql_free_statement(status, &stmth, DSQL_drop);
- *defer_break = FALSE;
- goto IBASE_EXIT;
- }
-
- if (result != NULL)
- result = string_cat(result, &ssize, &offset, US "\n", 1);
-
- /* Find the number of fields returned. If this is one, we don't add field
- names to the data. Otherwise we do. */
- if (out_sqlda->sqld == 1) {
- if (out_sqlda->sqlvar[0].sqlind == NULL || *out_sqlda->sqlvar[0].sqlind != -1) /* NULL value yields nothing */
- result =
- string_cat(result, &ssize, &offset, US buffer,
- fetch_field(buffer, sizeof(buffer),
- &out_sqlda->sqlvar[0]));
- }
-
- else
- for (i = 0; i < out_sqlda->sqld; i++) {
- int len = fetch_field(buffer, sizeof(buffer),
- &out_sqlda->sqlvar[i]);
-
- result =
- string_cat(result, &ssize, &offset,
- US out_sqlda->sqlvar[i].aliasname,
- out_sqlda->sqlvar[i].aliasname_length);
- result = string_cat(result, &ssize, &offset, US "=", 1);
-
- /* Quote the value if it contains spaces or is empty */
-
- if (*out_sqlda->sqlvar[i].sqlind == -1) { /* NULL value */
- result =
- string_cat(result, &ssize, &offset, US "\"\"", 2);
- }
-
- else if (buffer[0] == 0 || Ustrchr(buffer, ' ') != NULL) {
- int j;
- result =
- string_cat(result, &ssize, &offset, US "\"", 1);
- for (j = 0; j < len; j++) {
- if (buffer[j] == '\"' || buffer[j] == '\\')
- result =
- string_cat(result, &ssize, &offset,
- US "\\", 1);
- result =
- string_cat(result, &ssize, &offset,
- US buffer + j, 1);
- }
- result =
- string_cat(result, &ssize, &offset, US "\"", 1);
- } else {
- result =
- string_cat(result, &ssize, &offset, US buffer,
- len);
- }
- result = string_cat(result, &ssize, &offset, US " ", 1);
- }
+ if (result)
+ result = string_catn(result, US "\n", 1);
+
+ /* Find the number of fields returned. If this is one, we don't add field
+ names to the data. Otherwise we do. */
+ if (out_sqlda->sqld == 1)
+ {
+ if (out_sqlda->sqlvar[0].sqlind == NULL || *out_sqlda->sqlvar[0].sqlind != -1) /* NULL value yields nothing */
+ result = string_catn(result, US buffer,
+ fetch_field(buffer, sizeof(buffer),
+ &out_sqlda->sqlvar[0]));