isc_dsql_xml_buffer_fetch()

From InterBase

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

status_vector

ISC_STATUS*

Pointer to the error status vector

stmt_handle

isc_stmt_handle *

Pointer to a statement handle previously executed with isc_dsql_execute_statement() or ­isc_dsql_alloc_execute2().

da_version

unsigned short

Specifies that the XSQLDA descriptor, rather than SQLDA, should be used; set this value to 1.

buffer

char *

Pointer to a character buffer that holds the returned XML.

buffer_size

int

Size of <buffer>

xsqlda

XSQLDA *

Pointer to an optional, previously allocated XSQLDA used for results of statement execution.

ib_xmlda

IB_XMLDA*

Pointer to an initialized XML descriptor area, IB_XMLDA

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.

See Also

Advance To: