home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer) / NeXT_Developer-3.3.iso / usr / sybase / doc / dbadlen.man < prev    next >
Encoding:
Text File  |  1993-04-22  |  3.9 KB  |  133 lines

  1.  
  2.   1                       Version 4.0 -- 5/1/89                  dbadlen
  3.   ______________________________________________________________________
  4.  
  5.   NAME:  dbadlen
  6.  
  7.   FUNCTION:
  8.        Return the actual length of the data for a compute column.
  9.  
  10.   SYNTAX:
  11.        DBINT dbadlen(dbproc, computeid, column)
  12.  
  13.        DBPROCESS *dbproc;
  14.        int       computeid;
  15.        int       column;
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.   dbadlen                 Version 4.0 -- 5/1/89                        2
  25.   ______________________________________________________________________
  26.  
  27.   COMMENTS:
  28.  
  29.        o This routine returns the actual length of the data for  a  par-
  30.          ticular compute column.
  31.        o Use the dbaltlen() routine to determine  the  maximum  possible
  32.          length  for  the  data.   Use dbadata() to get a pointer to the
  33.          data.
  34.  
  35.        o Here's  a  program  fragment  that  illustrates  the   use   of
  36.          dbadlen():
  37.  
  38.          DBPROCESS       *dbproc;
  39.          char            biggest_name[MAXNAME+1];
  40.          int             namelen;
  41.          int             rowinfo;
  42.  
  43.          /* put the command into the command buffer */
  44.  
  45.  
  46.   3                       Version 4.0 -- 5/1/89                  dbadlen
  47.   ______________________________________________________________________
  48.          dbcmd(dbproc, "select name from sysobjects");
  49.          dbcmd(dbproc, " order by name");
  50.          dbcmd(dbproc, " compute max(name)");
  51.  
  52.          /* send the command to SQL Server and start execution */
  53.          dbsqlexec(dbproc);
  54.  
  55.          /* process the command */
  56.          dbresults(dbproc);
  57.  
  58.          /* examine each row returned by the command */
  59.          while ((rowinfo = dbnextrow(dbproc)) != NO_MORE_ROWS)
  60.          {
  61.              if (rowinfo == REG_ROW)
  62.                  printf("regular row returned.\n");
  63.              else
  64.              {
  65.  
  66.  
  67.  
  68.   dbadlen                 Version 4.0 -- 5/1/89                        4
  69.   ______________________________________________________________________
  70.                  /* This row is the result of a COMPUTE clause,
  71.                   * and "rowinfo" is the computeid of this COMPUTE
  72.                   * clause.
  73.                   */
  74.  
  75.                  namelen = dbadlen(dbproc, rowinfo, 1);
  76.                  strncpy
  77.                   (biggest_name,
  78.                    (char *)dbadata(dbproc, rowinfo, 1),
  79.                    namelen);
  80.  
  81.                  /* Data pointed to by dbadata() is not
  82.                   * null-terminated.
  83.                   */
  84.                  biggest_name[namelen] = '\0';
  85.  
  86.                  printf("biggest name = %s\n", biggest_name);
  87.  
  88.  
  89.  
  90.   5                       Version 4.0 -- 5/1/89                  dbadlen
  91.   ______________________________________________________________________
  92.              }
  93.          }
  94.  
  95.  
  96.   PARAMETERS:
  97.        dbproc -  A pointer to the DBPROCESS structure that provides  the
  98.            connection for a particular front-end/SQL Server process.  It
  99.            contains all the information that DB-Library uses  to  manage
  100.            communications and data between the front end and SQL Server.
  101.        computeid -  The id that identifies the particular compute row of
  102.            interest.   A  SQL SELECT statement may have multiple COMPUTE
  103.            clauses, each of which returns a separate compute  row.   The
  104.            computeid  corresponding  to  the  first  COMPUTE clause in a
  105.            SELECT is 1.  The computeid is  returned  by  dbnextrow()  or
  106.            dbgetrow().
  107.        column -  The number of the column of interest.  The first column
  108.            is number 1.
  109.  
  110.  
  111.  
  112.   dbadlen                 Version 4.0 -- 5/1/89                        6
  113.   ______________________________________________________________________
  114.  
  115.   RETURNS:
  116.        The length, in bytes,  of  the  data  for  a  particular  compute
  117.        column.  If  there is no such column or COMPUTE clause, dbadlen()
  118.        returns -1.  If the data has a null value, dbadlen() returns 0.
  119.  
  120.   SEE ALSO:
  121.        dbadata, dbaltlen, dbalttype, dbgetrow, dbnextrow, dbnumalts
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.