isc_dsql_sql_info()

From InterBase

Go Up to API Function Reference


Returns requested information about a prepared DSQL statement.

Syntax

 ISC_STATUS isc_dsql_sql_info(
 ISC_STATUS *status_vector,
 isc_stmt_handle *stmt_handle,
 unsigned short item_length,
 char *items,
 unsigned short buffer_length,
 char *buffer);
Parameter Type Description

status_vector

ISC_STATUS *

Pointer to the error status vector

stmt_handle

isc_stmt_handle *

Pointer to a statement handle previously allocated with isc_dsql_allocate_statement() or ­isc_dsql_alloc_statement2(); the handle returns an error in status_vector if it is NULL.

item_length

unsigned short

Number of bytes in the string of information items in items

items

char *

String of requested information items

buffer_length

unsigned short

Number of bytes in the result buffer, <buffer>

buffer

char *

User-provided buffer for holding returned data; must be large enough to hold the information requested.

Description

isc_dsql_sql_info() returns requested information about a statement prepared with a call to isc_dsql_prepare(). The main application need for this function is to determine the statement type of an unknown prepared statement, for example, a statement entered by the user at run time.

Requested information can include the:

  • Statement type
  • Number of input parameters required by the statement
  • Number of output values returned by the statement
  • Detailed information regarding each input parameter or output value, including its data type, scale, and length.
  • The query plan prepared by the optimizer

Example

The following illustrates a call to isc_dsql_sql_info() to determine the statement type of the statement whose handle is referenced by stmt:

int statement_type;
int length;
char type_item[] = {isc_info_sql_stmt_type};
char res_buffer[8];
isc_dsql_sql_info(status_vector,
&stmt, /* Allocated previously by isc_dsql_allocate_statement()
 * or isc_dsql_alloc_statement2() call. */
sizeof(type_item), type_item, sizeof(res_buffer), res_buffer);

if (res_buffer[0] == isc_info_sql_stmt_type) {
length = isc_portable_integer(buffer[1], 2);
statement_type = isc_portable_integer(buffer[3], length);
}

Return value

isc_dsql_sql_info() returns the second element of the status vector. Zero indicates success. A nonzero value indicates an error. For InterBase errors, the first element of the status vector is set to 1, and the second element is set to an InterBase error code.

To check for an InterBase error, examine the first two elements of the status vector directly. For more information about examining the status vector, see Handling Error Conditions.

For more information about determining unknown statement types at run time, see Determining an Unknown Statement Type at Runtime of Working with Dynamic SQL.

See Also

Advance To: