June 19, 2004

DBI bind_param_inout and MySQL

The short answer is that it doesn't work because bind_param_inout is not implemented for MySQL. For those of you that are curious, bind_param_inout allows you to pass a reference into an SQL statement instead of the actual block of data. It conserves memory since duplicate copies of the data do not have to exist. The error you might see if you try to do this is "Output parameters not implemented". That's too bad. I wonder why it isn't implemented.
/***************************************************************************
 *
 *  Name:    dbd_bind_ph
 *
 *  Purpose: Binds a statement value to a parameter
 *
 *  Input:   sth - statement handle
 *           imp_sth - drivers private statement handle data
 *           param - parameter number, counting starts with 1
 *           value - value being inserted for parameter "param"
 *           sql_type - SQL type of the value
 *           attribs - bind parameter attributes, currently this must be
 *               one of the values SQL_CHAR, ...
 *           inout - TRUE, if parameter is an output variable (currently
 *               this is not supported)
 *           maxlen - ???
 *
 *  Returns: TRUE for success, FALSE otherwise
 *
 **************************************************************************/

int dbd_bind_ph (SV *sth, imp_sth_t *imp_sth, SV *param, SV *value,
		 IV sql_type, SV *attribs, int is_inout, IV maxlen) {
    int paramNum = SvIV(param);

    if (paramNum <= 0  ||  paramNum > DBIc_NUM_PARAMS(imp_sth)) {
        do_error(sth, JW_ERR_ILLEGAL_PARAM_NUM,
		       "Illegal parameter number");
	return FALSE;
    }

    if (is_inout) {
        do_error(sth, JW_ERR_NOT_IMPLEMENTED,
		       "Output parameters not implemented");
	return FALSE;
    }

    return BindParam(&imp_sth->params[paramNum - 1], value, sql_type);
}
Posted by torque at June 19, 2004 8:38 AM | TrackBack
Comments

Tim,

Have you find any details about bind_param_inout support by mysql dbd driver. Please let me know if you have any clue. I'm unable to execute a stored procedure with out param.

Thanks,
Balaji

Posted by: balaji at March 18, 2005 10:28 AM
Post a comment









Remember personal info?