home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer) / NeXT_Developer-3.3.iso / NextLibrary / Documentation / Sybase / DBLIB / Section2 / dbdata.nr < prev    next >
Encoding:
Text File  |  1993-04-22  |  1.9 KB  |  72 lines

  1. .Na "dbdata" 
  2. .Aa
  3. .Fu
  4. Return a pointer to the data in a regular result column.
  5. .Ih "regular column data, getting"
  6. .Sy
  7. .Sf "BYTE *dbdata(dbproc, column)"
  8. .Sp "DBPROCESS" "*dbproc"
  9. .Sp "int" "column"
  10. .Co
  11. .Bl
  12. This routine returns a pointer to the data in a regular (\f2i.e.,\f1 non-compute)
  13. result column.
  14. The data is not null-terminated.  You can use
  15. .I "dbdatlen()"
  16. to get the length of the data.
  17. .Bl
  18. Here's a small program fragment that uses \f2dbdata()\fP:
  19. .ta +4n +4n +4n +4n +4n +4n
  20. .SD
  21. .so dbdata.ex
  22. .ED
  23. .Bl
  24. Do not add a null terminator to string data until you've copied it
  25. from the DBPROCESS with a routine such as \f2strncpy()\f1.
  26. For example:
  27. .ta +4n +4n +4n +4n +4n +4n
  28. .SD
  29. .ne 5
  30. char    objname[40]
  31.     ...
  32.  
  33. strncpy(objname, (char *)dbdata(dbproc,2), (int)dbdatlen(dbproc,2))
  34. objname[dbdatlen(dbproc,2] = '\e0'
  35. .ED
  36. .Bl
  37. The function
  38. .I "dbbind()"
  39. will automatically bind result data to your program variables.  It does a
  40. copy of the data, but is often easier to use than \f2dbdata()\f1.
  41. Furthermore, it includes a convenient type conversion capability.
  42. By means of this capability, the application can, among other things, 
  43. easily add a null terminator to a result string or convert money and datetime 
  44. data to printable strings.
  45. .Bz
  46. .Pa
  47. .Pi dbproc
  48. A pointer to the DBPROCESS structure that provides the connection
  49. for a particular front-end/\*S process.  It contains all the
  50. information that \*L uses to manage communications and data between the
  51. front end and \*S.
  52. .Pi column
  53. The number of the column of interest.  The first column is number 1.
  54. .in -.375i
  55. .Re
  56. .br
  57. A BYTE pointer to the data for the 
  58. particular column of interest.
  59. Be sure to cast this pointer into the proper type.
  60. A NULL BYTE pointer is returned if there is no such column
  61. or if the data has a null value.
  62. To make sure that the data is really a null value, you should always
  63. check for a return of 0 from 
  64. .I "dbdatlen()."
  65. .Sa
  66. dbbind,
  67. dbcollen,
  68. dbcolname,
  69. dbcoltype,
  70. dbdatlen,
  71. dbnumcols
  72.