home *** CD-ROM | disk | FTP | other *** search
- .Na "dbresults"
- .Aa
- .Fu
- Set up the results of the next query.
- .Ih "result data, getting"
- .Sy
- .Sf "RETCODE dbresults(dbproc)"
- .Sp "DBPROCESS" "*dbproc"
- .Co
- .Bl
- This routine sets up the next command in the command batch for processing.
- The application program calls it after
- .I "dbsqlexec()"
- or
- .I "dbsqlok()"
- returns SUCCEED.
- The first call to
- .I "dbresults()"
- will always return either SUCCEED or NO_MORE_RESULTS if
- the call to
- .I "dbsqlexec()"
- or
- .I "dbsqlok()"
- has returned SUCCEED.
- Once \f2dbresults()\f1 returns SUCCEED,
- the application typically processes any result rows with
- .I "dbnextrow()."
- .Bl
- To manage multiple input data streams efficiently, a UNIX
- application can confirm that unread bytes are available,
- either in the \*L network buffer (by calling \f2DBRBUF()\f1) or in the network itself
- (by calling the UNIX \f2select()\f1 function), before calling \f2dbresults()\f1.
- .Bl
- .I "dbresults()"
- must be called for each command in the command batch, whether or not the command returns
- any rows. If the application code
- doesn't know how many commands are in the batch (for example, if the application is
- designed to process ad hoc queries), it can call
- .I "dbresults()"
- until it returns NO_MORE_RESULTS.
- .sp 0.5v
- \f2dbresults()\f1 must also ordinarily
- be called once for any stored procedure executed in the command batch.
- .Ih "stored procedure results"
- .Ih "results, stored procedure"
- However, if the stored procedure contains more than one SQL SELECT statement,
- then \f2dbresults()\f1 must be called once for each SELECT.
- Again, the easiest way to do this is to continue to call \f2dbresults()\f1
- until it returns NO_MORE_RESULTS.
- .Bl
- To cancel the remaining results from the command batch (and eliminate the need to continue
- calling \f2dbresults()\f1 until it returns NO_MORE_RESULTS), call \f2dbcancel()\f1.
- .Bl
- To determine whether a particular command is one that returns rows and
- needs results processing with \f2dbnextrow()\f1, call \f2DBROWS()\f1 after
- the \f2dbresults()\f1 call.
- .Bl
- The typical sequence of calls for using \f2dbresults()\f1 with \f2dbsqlexec()\f1 is:
- .ta +4n +4n +4n +4n +4n +4n
- .SD
- .so dbresults.ex
- .ED
- Example 1 in the \f2\*L Reference Supplement\f1 shows how to use \f2dbresults()\f1 to process a multi-query command batch.
- .Bl
- Another use for
- \f2dbresults()\f1 is to process the results of a remote procedure
- call made with \f2dbrpcsend()\f1.
- See the \f2dbrpcsend()\f1 manual page for details.
- .Bl
- An asynchronous version of \f2dbresults()\f1, called \f2dbresults_a()\f1, is available for VMS.
- .Bz
- .Pa
- .Pi dbproc
- A pointer to the DBPROCESS structure that provides the connection
- for a particular front-end/\*S process. It contains all the
- information that \*L uses to manage communications and data between the
- front end and \*S.
- .in -.375i
- .Re
- .br
- SUCCEED, FAIL or NO_MORE_RESULTS.
- \f2dbresults()\f1 returns
- NO_MORE_RESULTS if all commands in the buffer have already been processed.
- The most common reason for failing is a run-time error, such as a database permission violation.
- .sp 0.5v
- The number of commands in the command buffer determines whether \f2dbsqlexec()\f1 or \f2dbresults()\f1
- traps a run-time error.
- If the buffer contains only a single command, a run-time error will cause
- \f2dbsqlexec()\f1 to fail.
- If the command buffer contains multiple commands,
- a run-time error will \f2not\f1 cause \f2dbsqlexec()\f1 to fail.
- Instead, the \f2dbresults()\f1 call that processes the command causing the run-time error will fail.
- .sp 0.5v
- The situation is a bit more complicated for run-time errors and stored procedures.
- A run-time error on an EXECUTE command may cause \f2dbresults()\f1 to fail,
- in accordance with the rule given in the previous paragraph.
- A run-time error on a statement \f2inside\f1 a stored procedure will not cause \f2dbresults()\f1 to fail,
- however.
- For example, if the stored procedure contains an INSERT statement and the user does not have
- insert permission on the database table, the INSERT statement will fail, but \f2dbresults()\f1
- will still return SUCCEED.
- To check for run-time errors inside stored procedures, use the \f2dbretstatus()\f1 routine
- to look at the procedure's return status, and trap relevant \*S messages inside your message handler.
- .Sa
- dbbind,
- dbcancel,
- dbnextrow,
- DBRBUF,
- dbresults_a,
- dbretstatus,
- DBROWS,
- dbrpcsend,
- dbsqlexec,
- dbsqlok
-