home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer) / NeXT_Developer-3.3.iso / NextLibrary / Documentation / Sybase / DBLIB / Section2 / dbadlen.ex < prev    next >
Encoding:
Text File  |  1993-04-22  |  973 b   |  43 lines

  1. DBPROCESS       *dbproc;
  2. char            biggest_name[MAXNAME+1];
  3. int             namelen;
  4. int             rowinfo;
  5.  
  6. /* put the command into the command buffer */
  7. dbcmd(dbproc, "select name from sysobjects");
  8. dbcmd(dbproc, " order by name");
  9. dbcmd(dbproc, " compute max(name)");
  10.  
  11. /* send the command to \*S and start execution */
  12. dbsqlexec(dbproc);
  13.  
  14. /* process the command */
  15. dbresults(dbproc);
  16.  
  17. /* examine each row returned by the command */
  18. while ((rowinfo = dbnextrow(dbproc)) != NO_MORE_ROWS)
  19. {
  20.     if (rowinfo == REG_ROW)
  21.         printf("regular row returned.\\n");
  22.     else
  23.     {
  24.         /* This row is the result of a COMPUTE clause,
  25.          * and "rowinfo" is the computeid of this COMPUTE
  26.          * clause.
  27.          */
  28.  
  29.         namelen = dbadlen(dbproc, rowinfo, 1);
  30.         strncpy
  31.          (biggest_name,
  32.           (char *)dbadata(dbproc, rowinfo, 1),
  33.           namelen);
  34.  
  35.         /* Data pointed to by dbadata() is not
  36.          * null-terminated.
  37.          */
  38.         biggest_name[namelen] = '\\0';
  39.  
  40.         printf("biggest name = %s\\n", biggest_name);
  41.     }
  42. }
  43.