in driver/options.cc [619:789]
SQLINTEGER StringLengthPtr __attribute__((unused)))
{
STMT *stmt= (STMT *)hstmt;
SQLRETURN result= SQL_SUCCESS;
STMT_OPTIONS *options= &stmt->stmt_options;
CLEAR_STMT_ERROR(stmt);
switch (Attribute)
{
case SQL_ATTR_CURSOR_SCROLLABLE:
if (ValuePtr == (SQLPOINTER)SQL_NONSCROLLABLE &&
options->cursor_type != SQL_CURSOR_FORWARD_ONLY)
options->cursor_type= SQL_CURSOR_FORWARD_ONLY;
else if (ValuePtr == (SQLPOINTER)SQL_SCROLLABLE &&
options->cursor_type == SQL_CURSOR_FORWARD_ONLY)
options->cursor_type= SQL_CURSOR_STATIC;
break;
case SQL_ATTR_APP_PARAM_DESC:
case SQL_ATTR_APP_ROW_DESC:
{
DESC *desc= (DESC *) ValuePtr;
DESC **dest= NULL;
desc_desc_type desc_type = DESC_UNKNOWN;
if (Attribute == SQL_ATTR_APP_PARAM_DESC)
{
dest= &stmt->apd;
desc_type= DESC_PARAM;
}
else if (Attribute == SQL_ATTR_APP_ROW_DESC)
{
dest= &stmt->ard;
desc_type= DESC_ROW;
}
(*dest)->stmt_list_remove(stmt);
/* reset to implicit if null */
if (desc == SQL_NULL_HANDLE)
{
if (Attribute == SQL_ATTR_APP_PARAM_DESC)
stmt->apd= stmt->imp_apd;
else if (Attribute == SQL_ATTR_APP_ROW_DESC)
stmt->ard= stmt->imp_ard;
break;
}
if (desc->alloc_type == SQL_DESC_ALLOC_AUTO &&
desc->stmt != stmt)
return ((STMT*)hstmt)->set_error(MYERR_S1017,
"Invalid use of an automatically allocated "
"descriptor handle",0);
if (desc->alloc_type == SQL_DESC_ALLOC_USER &&
stmt->dbc != desc->dbc)
return ((STMT*)hstmt)->set_error(MYERR_S1024,
"Invalid attribute value",0);
if (desc->desc_type != DESC_UNKNOWN &&
desc->desc_type != desc_type)
{
return ((STMT*)hstmt)->set_error(MYERR_S1024,
"Descriptor type mismatch",0);
}
assert(desc);
assert(dest);
desc->stmt_list_add(stmt);
desc->desc_type= desc_type;
*dest= desc;
}
break;
case SQL_ATTR_AUTO_IPD:
case SQL_ATTR_ENABLE_AUTO_IPD:
if (ValuePtr != (SQLPOINTER)SQL_FALSE)
return ((STMT*)hstmt)->set_error(MYERR_S1C00,
"Optional feature not implemented",0);
break;
case SQL_ATTR_IMP_PARAM_DESC:
case SQL_ATTR_IMP_ROW_DESC:
return ((STMT*)hstmt)->set_error(MYERR_S1024,
"Invalid attribute/option identifier",0);
case SQL_ATTR_PARAM_BIND_OFFSET_PTR:
return stmt_SQLSetDescField(stmt, stmt->apd, 0,
SQL_DESC_BIND_OFFSET_PTR,
ValuePtr, SQL_IS_POINTER);
case SQL_ATTR_PARAM_BIND_TYPE:
return stmt_SQLSetDescField(stmt, stmt->apd, 0,
SQL_DESC_BIND_TYPE,
ValuePtr, SQL_IS_INTEGER);
case SQL_ATTR_PARAM_OPERATION_PTR: /* need to support this ....*/
return stmt_SQLSetDescField(stmt, stmt->apd, 0,
SQL_DESC_ARRAY_STATUS_PTR,
ValuePtr, SQL_IS_POINTER);
case SQL_ATTR_PARAM_STATUS_PTR: /* need to support this ....*/
return stmt_SQLSetDescField(stmt, stmt->ipd, 0,
SQL_DESC_ARRAY_STATUS_PTR,
ValuePtr, SQL_IS_POINTER);
case SQL_ATTR_PARAMS_PROCESSED_PTR: /* need to support this ....*/
return stmt_SQLSetDescField(stmt, stmt->ipd, 0,
SQL_DESC_ROWS_PROCESSED_PTR,
ValuePtr, SQL_IS_POINTER);
case SQL_ATTR_PARAMSET_SIZE:
return stmt_SQLSetDescField(stmt, stmt->apd, 0,
SQL_DESC_ARRAY_SIZE,
ValuePtr, SQL_IS_ULEN);
case SQL_ATTR_ROW_ARRAY_SIZE:
case SQL_ROWSET_SIZE:
return stmt_SQLSetDescField(stmt, stmt->ard, 0,
SQL_DESC_ARRAY_SIZE,
ValuePtr, SQL_IS_ULEN);
case SQL_ATTR_ROW_BIND_OFFSET_PTR:
return stmt_SQLSetDescField(stmt, stmt->ard, 0,
SQL_DESC_BIND_OFFSET_PTR,
ValuePtr, SQL_IS_POINTER);
case SQL_ATTR_ROW_BIND_TYPE:
return stmt_SQLSetDescField(stmt, stmt->ard, 0,
SQL_DESC_BIND_TYPE,
ValuePtr, SQL_IS_INTEGER);
case SQL_ATTR_ROW_NUMBER:
return ((STMT*)hstmt)->set_error(MYERR_S1000,
"Trying to set read-only attribute",0);
case SQL_ATTR_ROW_OPERATION_PTR:
return stmt_SQLSetDescField(stmt, stmt->ard, 0,
SQL_DESC_ARRAY_STATUS_PTR,
ValuePtr, SQL_IS_POINTER);
case SQL_ATTR_ROW_STATUS_PTR:
return stmt_SQLSetDescField(stmt, stmt->ird, 0,
SQL_DESC_ARRAY_STATUS_PTR,
ValuePtr, SQL_IS_POINTER);
case SQL_ATTR_ROWS_FETCHED_PTR:
return stmt_SQLSetDescField(stmt, stmt->ird, 0,
SQL_DESC_ROWS_PROCESSED_PTR,
ValuePtr, SQL_IS_POINTER);
case SQL_ATTR_SIMULATE_CURSOR:
options->simulateCursor= (SQLUINTEGER)(SQLULEN)ValuePtr;
break;
/*
3.x driver doesn't support any statement attributes
at connection level, but to make sure all 2.x apps
works fine...lets support it..nothing to lose..
*/
default:
result= set_constmt_attr(3,hstmt,options,
Attribute,ValuePtr);
}
return result;
}