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

  1.  
  2.   1                       Version 4.0 -- 5/1/89                   dbdata
  3.   ______________________________________________________________________
  4.  
  5.   NAME:  dbdata
  6.  
  7.   FUNCTION:
  8.        Return a pointer to the data in a regular result column.
  9.  
  10.   SYNTAX:
  11.        BYTE *dbdata(dbproc, column)
  12.  
  13.        DBPROCESS *dbproc;
  14.        int       column;
  15.  
  16.   COMMENTS:
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.   dbdata                  Version 4.0 -- 5/1/89                        2
  25.   ______________________________________________________________________
  26.  
  27.        o This routine returns a pointer to the data in a regular  (i.e.,
  28.          non-compute)  result  column.  The data is not null-terminated.
  29.          You can use dbdatlen() to get the length of the data.
  30.        o Here's a small program fragment that uses dbdata():
  31.  
  32.          DBPROCESS       *dbproc;
  33.          DBINT           row_number = 0;
  34.          DBINT           object_id;
  35.  
  36.          /* put the command into the command buffer */
  37.          dbcmd(dbproc, "select id from sysobjects");
  38.  
  39.          /* send the command to SQL Server and begin execution */
  40.          dbsqlexec(dbproc);
  41.  
  42.          /* process the command results */
  43.  
  44.  
  45.  
  46.   3                       Version 4.0 -- 5/1/89                   dbdata
  47.   ______________________________________________________________________
  48.          dbresults(dbproc);
  49.  
  50.          /* examine the data in each row */
  51.          while (dbnextrow(dbproc) != NO_MORE_ROWS)
  52.          {
  53.              row_number++;
  54.              object_id = *((DBINT *)dbdata(dbproc, 1));
  55.              printf("row %ld, object id is %ld.\n", row_number,
  56.                  object_id);
  57.          }
  58.  
  59.  
  60.        o Do not add a null terminator to string data until you've copied
  61.          it  from  the  DBPROCESS with a routine such as strncpy().  For
  62.          example:
  63.  
  64.  
  65.  
  66.  
  67.  
  68.   dbdata                  Version 4.0 -- 5/1/89                        4
  69.   ______________________________________________________________________
  70.          char    objname[40]
  71.              ...
  72.  
  73.          strncpy(objname, (char *)dbdata(dbproc,2), (int)dbdatlen(dbproc,2))
  74.          objname[dbdatlen(dbproc,2] = '\0'
  75.  
  76.  
  77.        o The function dbbind() will automatically bind  result  data  to
  78.          your  program  variables.   It  does a copy of the data, but is
  79.          often easier to use than dbdata().  Furthermore, it includes  a
  80.          convenient  type conversion capability.  By means of this capa-
  81.          bility, the application can, among other things, easily  add  a
  82.          null  terminator  to a result string or convert money and date-
  83.          time data to printable strings.
  84.  
  85.   PARAMETERS:
  86.        dbproc -  A pointer to the DBPROCESS structure that provides  the
  87.            connection for a particular front-end/SQL Server process.  It
  88.  
  89.  
  90.   5                       Version 4.0 -- 5/1/89                   dbdata
  91.   ______________________________________________________________________
  92.            contains all the information that DB-Library uses  to  manage
  93.            communications and data between the front end and SQL Server.
  94.        column -  The number of the column of interest.  The first column
  95.            is number 1.
  96.  
  97.   RETURNS:
  98.        A BYTE pointer to the data for the particular column of interest.
  99.        Be  sure  to cast this pointer into the proper type.  A NULL BYTE
  100.        pointer is returned if there is no such column or if the data has
  101.        a null value.  To make sure that the data is really a null value,
  102.        you should always check for a return of 0 from dbdatlen().
  103.  
  104.   SEE ALSO:
  105.        dbbind, dbcollen, dbcolname, dbcoltype, dbdatlen, dbnumcols
  106.  
  107.  
  108.  
  109.  
  110.  
  111.