home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 for Intel / NeXTSTEP 3.2 for Intel.iso / NextLibrary / Documentation / Sybase / DBLIB / Section2 / dbadata.nr < prev    next >
Encoding:
Text File  |  1993-04-22  |  3.2 KB  |  100 lines

  1. .Na "dbadata" 
  2. .Aa
  3. .Fu
  4. Return a pointer to the data for a compute column.
  5. .Ih "compute column data, getting"
  6. .Sy
  7. .Sf "BYTE *dbadata(dbproc, computeid, column)"
  8. .Sp "DBPROCESS" "*dbproc"
  9. .Sp "int" "computeid"
  10. .Sp "int" "column"
  11. .Co
  12. .Bl
  13. After each call to 
  14. .I "dbnextrow()",
  15. you can use this routine to return a pointer to the data for a particular
  16. column in a compute row.  The data is not null-terminated.  You can use
  17. .I "dbadlen()"
  18. to get the length of the data.
  19. .Bl
  20. When a column of integer data is summed or averaged, \*S always returns a 4-byte integer,
  21. regardless of the size of the column. 
  22. Therefore, be sure that the variable which is to contain the result from such a compute 
  23. is declared as DBINT.
  24. .Bl
  25. Here's a short program fragment which illustrates the use of \f2dbadata()\fP:
  26. .ta +4n +4n +4n +4n +4n +4n
  27. .SD
  28. .so dbadata.ex
  29. .ED
  30. .Bl
  31. The function
  32. .I "dbaltbind()"
  33. automatically binds compute data to your program variables.
  34. It does a copy of the data, but is often easier to use than \f2dbadata()\f1.
  35. Furthermore, it includes a convenient type conversion capability.
  36. By means of this capability, the application can, among other things, 
  37. easily add a null terminator to a result string or convert money and datetime 
  38. data to printable strings.
  39. .Bz
  40. .Pa
  41. .Pi dbproc
  42. A pointer to the DBPROCESS structure that provides the connection
  43. for a particular front-end/\*S process.  It contains all the
  44. information that \*L uses to manage communications and data between the
  45. front end and \*S.
  46. .Pi computeid
  47. The id that identifies the particular compute row of interest.
  48. A SQL SELECT statement may have multiple COMPUTE clauses, 
  49. each of which returns a separate compute row.
  50. The \f2computeid\f1 corresponding to the
  51. first COMPUTE clause in a SELECT is 1.
  52. The \f2computeid\f1 is returned by \f2dbnextrow()\f1 
  53. or \f2dbgetrow().\f1
  54. .Pi column
  55. The number of the column of interest.  The first column returned is number 1.
  56. Note that the order in which compute columns are returned is determined by the order 
  57. of the corresponding columns in the \f2select-list\f1, not by the order in which the
  58. compute columns were originally specified.
  59. For example, in the following query the result of ``sum(price)'' is referenced by giving
  60. \f2column\f1 a value of 1, not 2:
  61. .SD
  62. .in +5n
  63. .ne 2
  64. select price, advance from titles
  65.     compute sum(advance), sum(price)
  66. .in -5n
  67. .ED
  68. The relative order of compute columns in the \f2select-list\f1, rather than their absolute
  69. position, determines the value of \f2column\f1.
  70. For instance, given the following variation of the previous SELECT:
  71. .SD
  72. .in +5n
  73. .ne 2
  74. select title_id, price, advance from titles
  75.     compute sum(advance), sum(price)
  76. .in -5n
  77. .ED
  78. the \f2column\f1 for ``sum(price)'' still has a value of 1 and not 2, 
  79. because the ``title_id'' column in the \f2select-list\f1
  80. is not a compute column and therefore is ignored when determining the compute column's number.
  81. .in -.375i
  82. .Re
  83. .br
  84. A BYTE pointer to the data for a 
  85. particular column in a particular compute.
  86. Be sure to cast this pointer into the proper type.
  87. A BYTE pointer to NULL is returned if there is no such column or compute
  88. or if the data has a null value.
  89. .sp
  90. \*L allocates and frees the data space that the BYTE pointer points to.
  91. Do not overwrite this space.
  92. .Sa
  93. dbadlen,
  94. dbaltbind,
  95. dbaltlen,
  96. dbalttype,
  97. dbgetrow,
  98. dbnextrow,
  99. dbnumalts
  100.