isc_dsql_xml_buffer_fetch()
Go Up to API Function Reference
Returns XML-formatted text to the specified buffer.
Syntax
int isc_dsql_xml_buffer_fetch(
ISC_STATUS *status_vector,
isc_stmt_handle *stmt_handle,
unsigned short da_version,
char *buffer
int buffer_size
XSQLDA *xsqlda,
IB_XMLDA *ib_xmlda);
Parameter | Type | Description |
---|---|---|
|
|
Pointer to the error status vector |
|
isc_stmt_handle * |
Pointer to a statement handle previously executed with |
|
unsigned short |
Specifies that the |
|
char * |
Pointer to a character buffer that holds the returned XML. |
buffer_size |
int |
Size of <buffer> |
|
|
Pointer to an optional, previously allocated |
|
|
Pointer to an initialized XML descriptor area, |
Description
isc_dsql_buffer_fetch()
returns XML-formatted text to the buffer
. It must be called more than once to complete the file if the buffer is not large enough to hold the data. If you are interested in looking at the data one row at a time, use isc_dsql_xml_fetch()
.
In order to use isc_dsql_xml_buffer_fetch()
, you must allocate a character array, buffer
, that is at least 1024 bytes long. The buffer_size
argument reports the size of this passed buffer. The function does not return incomplete headers, footers, or records. It sets xmlda_more_data
if the call should be made once again to get the complete XML buffer.
Example
The following example retrieves data from a previously prepared and executed statement handle and prints the XML to stdout
;
int buff_size = 2048; . . . while (!done){ char *buffer = malloc (buff_size); int size; /* the buffer mode .. */ size = isc_dsql_xml_buffer_fetch( status, &stmt, buffer, buff_size, 1, sqlda, &xmlda); if (size == -2) { /* must increase the size of the buffer */ buff_size = buff_size + 1024; done = 0; } else if (size == -1) { /* not enough memory break out */ printf ("out of memory /n"); free (buffer); break; } else { printf ("%s", buffer); if (xmlda.xmlda_more_data) done = 0; else done = 1; } free (buffer); }
For a complete example of how to generate XML from an InterBase table, see Exporting XML.
Return value
The function returns the number of characters written into the buffer (without the terminating null character). It returns –1 if there is not enough memory for it to continue, or –2 if the buffer is too small.