Microsoft KB Archive/63968

INF: Separate dbprocs Are Needed for Query & Update Operations

PSS ID Number: Q63968 Article last modified on 02-03-1994

1.00 1.10 OS/2

Question
Whenever I use dbcmd to do an SQL Server SELECT query that returns more than one row, and process each row sequentially with dbnextrow, I get the following DB-LIBRARY error message whenever I attempt an SQL Server UPDATE statement on the latest row received from dbnextrow: Attempting new SQL operation with results pending Why can’t I do an UPDATE operation on the current row, when there are still some outstanding rows that have not been processed with dbnextrow?

Response
Separate dbprocs are needed for the query and update operations. The following code segment illustrates the necessary operations: DBPROCESS q_dbproc, u_dbproc; q_dbproc = dbopen( login, SERVERNAME); u_dbproc = dbopen( login, SERVERNAME); dbcmd(q_dbproc,“select au_lname from pubs..authors”); dbsqlexec(dbproc); if (dbresults(q_dbproc) == SUCCEED) { dbbind(q_dbproc,1,STRINGBIND, (DBINT) 0, name); while (dbnextrow(q_dbproc) != NO_MORE_ROWS) { printf(“Name : %s”,name); dbcmd(u_dbproc,“update pubs..authors set …..”); dbsqlexec(u_dbproc); dbresults(u_dbproc); …. } } dbexit;

Additional reference words: 1.00 1.10 dblib db-lib Copyright Microsoft Corporation 1994.