home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 for Intel / NeXTSTEP 3.2 for Intel.iso / NextLibrary / Documentation / Sybase / DBLIB / Section2 / dbadata.ex next >
Encoding:
Text File  |  1993-04-22  |  764 b   |  31 lines

  1. DBPROCESS       *dbproc;
  2. int             rowinfo;
  3. DBINT           sum;
  4.  
  5. /* first, put the commands into the command buffer */
  6. dbcmd(dbproc, "select db_name(dbid), dbid, size from sysusages");
  7. dbcmd(dbproc, " order by dbid");
  8. dbcmd(dbproc, " compute sum(size) by dbid");
  9.  
  10. /* send the commands to \*S and start execution */
  11. dbsqlexec(dbproc);
  12.  
  13. /* process the command */
  14. dbresults(dbproc);
  15.  
  16. /* examine the results of the COMPUTE clause */
  17. while((rowinfo = dbnextrow(dbproc)) != NO_MORE_ROWS)
  18. {
  19.     if (rowinfo == REG_ROW)
  20.         printf("regular row returned.\\n");
  21.     else
  22.     {
  23.         /* This row is the result of a COMPUTE clause, and
  24.          * "rowinfo" is the computeid of this COMPUTE clause.
  25.          */
  26.  
  27.         sum = *(DBINT *)(dbadata(dbproc, rowinfo, 1));
  28.         printf("sum = %ld\\n", sum);
  29.     }
  30. }
  31.