Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int ncols, ncol;
- char **values;
- ncols = dbnumcols(dbproc);
- for (ncol = 0; ncol < ncols; ncol++)
- {
- int col_type = dbcoltype(dbproc, ncol + 1);
- if (dbwillconvert(col_type, SYBCHAR) != FALSE)
- {
- DBINT data_len;
- BYTE* data;
- data_len = dbdatlen(dbproc, ncol + 1);
- data = dbdata(dbproc, ncol + 1);
- if (data_len == 0) /* column is NULL */
- {
- values[ncol] = NULL;
- }
- else if (data == NULL) /* column is NULL, but probably shouldn't be */
- {
- values[ncol] = NULL;
- }
- else
- {
- char *value;
- int ret_value;
- int dest_len = 1000; /* any portable way to get real length of converted value? */
- if ((value = malloc(dest_len * sizeof(char))) == NULL) /* malloc failure */
- {
- /* raise error*/
- }
- ret_value = dbconvert(dbproc, col_type, data, data_len, SYBCHAR, (BYTE *) value, -1);
- if (ret_value == -1) /* conversion failure */
- {
- values[ncol] = NULL;
- }
- else
- {
- /* success: move value to values[ncol] */
- }
- }
- }
- else /* cannot be converted to SYBCHAR */
- {
- /* raise error */
- }
- }
Add Comment
Please, Sign In to add comment