Hi guys,

i have a problem,

i want to fetch many rows per bulk fetch.

so i took the manual from IBM and coded as it is described.

But when i execute SQLFetchScroll it last 10 seconds and then i got an
access violation.

So now i inspected the col-buffers for colwise binding and i see the right
values.

So i thougt, aha freddy, you read to many rows. but it doesnt work.

So i reduce the count of rows in the database to 20, increase the arrays to
100, try again,
same result ( access violation).
It seems to me, the driver don't stop reading after the last row.

Here some code-extracts:

sqlret = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &m_hstmt);
if (sqlret == SQL_SUCCESS || sqlret == SQL_SUCCESS_WITH_INFO)
{
SQLSetStmtAttr(m_hstmt, SQL_ATTR_NOSCAN, (void *)SQL_NOSCAN_ON,0);
}

SQLUINTEGER iArraySize = ARRAY_SIZE;
SQLRETURN sqlret;
BOOL ret = FALSE;
char sSqlString[200];

sqlret = SQLSetStmtAttr( m_hstmt, SQL_ATTR_ROW_BIND_TYPE,
SQL_BIND_BY_COLUMN, SQL_IS_INTEGER );
if (sqlret == SQL_SUCCESS || sqlret == SQL_SUCCESS_WITH_INFO)
{
sqlret = SQLSetStmtAttr( m_hstmt, SQL_ATTR_ROW_ARRAY_SIZE, &iArraySize,
SQL_IS_INTEGER );
if (sqlret == SQL_SUCCESS || sqlret == SQL_SUCCESS_WITH_INFO)
{
sqlret = SQLSetStmtAttr( m_hstmt, SQL_ATTR_ROW_STATUS_PTR,
m_iRowStatusArray, SQL_IS_POINTER );
if (sqlret == SQL_SUCCESS || sqlret == SQL_SUCCESS_WITH_INFO)
{
sqlret = SQLSetStmtAttr( m_hstmt, SQL_ATTR_ROWS_FETCHED_PTR,
&m_iNumRowsFetched, SQL_IS_POINTER );
}
else
{
m_pDataBase->DirectError(ERR_FATAL, SQL_EXEC_DIRECT, SQL_HANDLE_STMT,
m_hstmt, &m_sSqlString);
}
}
else
{
m_pDataBase->DirectError(ERR_FATAL, SQL_EXEC_DIRECT, SQL_HANDLE_STMT,
m_hstmt, &m_sSqlString);
}
}
else
{
m_pDataBase->DirectError(ERR_FATAL, SQL_EXEC_DIRECT, SQL_HANDLE_STMT,
m_hstmt, &m_sSqlString);
}
sqlret = SQLPrepare( m_hstmt, (unsigned char*)(&sSqlString[0]), SQL_NTS );
if (sqlret == SQL_SUCCESS || sqlret == SQL_SUCCESS_WITH_INFO)
{
sqlret = SQLExecute( m_hstmt );
if (sqlret == SQL_SUCCESS || sqlret == SQL_SUCCESS_WITH_INFO)
{
m_eof = FALSE;
}
else
{
m_pDataBase->DirectError(ERR_FATAL, SQL_EXEC_DIRECT, SQL_HANDLE_STMT,
m_hstmt, &m_sSqlString);
return FALSE;
}
}
else
{
m_pDataBase->DirectError(ERR_FATAL, SQL_EXEC_DIRECT, SQL_HANDLE_STMT,
m_hstmt, &m_sSqlString);
}

memset( &m_refkey[0], 0, (ARRAY_SIZE * sizeof(SQLINTEGER)));
memset( &m_refkey_ind[0], 0, (ARRAY_SIZE * sizeof(SQLINTEGER)));

// Spalten binden
sqlret = SQLBindCol( m_hstmt, 1, SQL_C_SLONG, m_refkey, sizeof(long),
m_refkey_ind );
if (sqlret == SQL_SUCCESS || sqlret == SQL_SUCCESS_WITH_INFO)
{
ret = TRUE;
}
else
{
m_pDataBase->DirectError(ERR_FATAL, SQL_EXEC_DIRECT, SQL_HANDLE_STMT,
m_hstmt, &m_sSqlString);
}
}
else
{
m_pDataBase->DirectError(ERR_FATAL, SQL_EXEC_DIRECT, SQL_HANDLE_STMT,
m_hstmt, &m_sSqlString);
}

// Und schon mal die ersten Saetze holen
sqlret = SQLFetchScroll(m_hstmt, SQL_FETCH_NEXT, 0); -> Here i got the
crash
if (sqlret == SQL_SUCCESS || sqlret == SQL_SUCCESS_WITH_INFO)
{

== End of example
I tried to execute it on DB2 6.1 and 7.2

Please tell me where is the error.

Freddy