Home | Previous Page | Next Page   Creating User-Defined Routines > Developing a User-Defined Routine > Creating UDR Code >

SQL Statement Execution

The differences in the execution of SQL statements in a C UDR and a client LIBMI application are because of the differences in passing mechanisms that they use for the contents of an MI_DATUM structure. In a C UDR, you must consider the data type of the value in the MI_DATUM structure to determine how to obtain the value. For more information on the passing mechanism for an MI_DATUM value, see Contents of an MI_DATUM Structure.

In SQL statement execution, the DataBlade API uses an MI_DATUM structure for the following values:

Setting Input Parameters

When you send a prepared statement for execution, you pass any input-parameter values in MI_DATUM structures. Therefore, the data type of the column associated with an input parameter determines the passing mechanism for the input-parameter value, as follows:

Within your C UDR, you must use the column data type to determine how to assign the input-parameter value in the MI_DATUM structure. To assign the input-parameter values, you send an array of MI_DATUM structures to the mi_exec_prepared_statement( ) or mi_open_prepared_statement( ) function, which sends the prepared statement to the database server for execution. For more information, see Assigning Values to Input Parameters.

Retrieving Column Values

When you execute a query (SELECT or EXECUTE FUNCTION statement) in a C UDR, you choose a control mode for the retrieved data. If the query data is in binary representation, the column value that mi_value( ) or mi_value_by_name( ) passes back is in an MI_DATUM structure. Therefore, the size of the data type associated with the column determines the passing mechanism for the column value, as follows:

Within your C UDR, you must use the column data type to determine how to obtain the column value in the MI_DATUM structure. For more information, see Obtaining Column Values.

Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]