Re: SQLPrepare with SQLFetchScroll???? Can it be done?
Posted in 2006
You should be using SQL_ATTR_ROW_ARRAY_SIZE statement attribute to get the number of rows you are looking for. That way I don't think you really have to loop it around. SQLFetch/SQLFetchScroll call will return the said number of rows (for more information about excepational situations refer MSDN help for SQLFetchScroll) in the application specified buffer (using SQLBindCol). Also, to know how many rows actually has been fetched you need to set the SQL_ATTR_ROWS_FETCHED_PTR statment attribute. Refer MSDN for SQLFetchScroll/SQLFetch to get more info in this regard. Also, you shouldn't be doing SQLPrepare() inside the loop....SQLPrepare needs to be called only once for a given query. HTH ... Thanks -Shesh "kjuliff@gmail.com" <kjuliff@gmail.com> Sent by: informix-list-bounces@iiug.org 07/25/2006 03:00 AM To informix-list@iiug.org cc Subject SQLPrepare with SQLFetchScroll???? Can it be done? The snippet of example code below os how I'm setting up a select with a where clause. I don't want to have a loop to get all the rows and I read about SQLFetchScroll. But for the life of me I can't work out how I can get all the qualifying rows from this SQLFetchScroll. It seems to me that the SQLFetchScroll can't be in the same code block as SQLPrepare? But then, how can I selectively return rows from a table? I can't even find a book on this stuff and it's driving me bananas. Any help AT all will be appreciated, Kate /* gets ONE row */ ret = SQLPrepare( hstmt, "select * from num_test where role_id = ?", SQL_NTS ); ival = 0; ret = SQLBindParameter( hstmt, 1, SQL_PARAM_INPUT, SQL_C_DOUBLE, SQL_NUMERIC, 0, 0, &dval, sizeof( dval ), &ival ); dval = 1.0; ret = SQLExecute( hstmt ); ret = SQLFetch( hstmt ); ret = SQLGetData( hstmt, 1, SQL_C_CHAR, str, sizeof( str ), &ival ); _______________________________________________ Informix-list mailing list Informix-list@iiug.org http://www.iiug.org/mailman/listinfo/informix-list