home *** CD-ROM | disk | FTP | other *** search
- .Na "dbadata"
- .Aa
- .Fu
- Return a pointer to the data for a compute column.
- .Ih "compute column data, getting"
- .Sy
- .Sf "BYTE *dbadata(dbproc, computeid, column)"
- .Sp "DBPROCESS" "*dbproc"
- .Sp "int" "computeid"
- .Sp "int" "column"
- .Co
- .Bl
- After each call to
- .I "dbnextrow()",
- you can use this routine to return a pointer to the data for a particular
- column in a compute row. The data is not null-terminated. You can use
- .I "dbadlen()"
- to get the length of the data.
- .Bl
- When a column of integer data is summed or averaged, \*S always returns a 4-byte integer,
- regardless of the size of the column.
- Therefore, be sure that the variable which is to contain the result from such a compute
- is declared as DBINT.
- .Bl
- Here's a short program fragment which illustrates the use of \f2dbadata()\fP:
- .ta +4n +4n +4n +4n +4n +4n
- .SD
- .so dbadata.ex
- .ED
- .Bl
- The function
- .I "dbaltbind()"
- automatically binds compute data to your program variables.
- It does a copy of the data, but is often easier to use than \f2dbadata()\f1.
- Furthermore, it includes a convenient type conversion capability.
- By means of this capability, the application can, among other things,
- easily add a null terminator to a result string or convert money and datetime
- data to printable strings.
- .Bz
- .Pa
- .Pi dbproc
- A pointer to the DBPROCESS structure that provides the connection
- for a particular front-end/\*S process. It contains all the
- information that \*L uses to manage communications and data between the
- front end and \*S.
- .Pi computeid
- The id that identifies the particular compute row of interest.
- A SQL SELECT statement may have multiple COMPUTE clauses,
- each of which returns a separate compute row.
- The \f2computeid\f1 corresponding to the
- first COMPUTE clause in a SELECT is 1.
- The \f2computeid\f1 is returned by \f2dbnextrow()\f1
- or \f2dbgetrow().\f1
- .Pi column
- The number of the column of interest. The first column returned is number 1.
- Note that the order in which compute columns are returned is determined by the order
- of the corresponding columns in the \f2select-list\f1, not by the order in which the
- compute columns were originally specified.
- For example, in the following query the result of ``sum(price)'' is referenced by giving
- \f2column\f1 a value of 1, not 2:
- .SD
- .in +5n
- .ne 2
- select price, advance from titles
- compute sum(advance), sum(price)
- .in -5n
- .ED
- The relative order of compute columns in the \f2select-list\f1, rather than their absolute
- position, determines the value of \f2column\f1.
- For instance, given the following variation of the previous SELECT:
- .SD
- .in +5n
- .ne 2
- select title_id, price, advance from titles
- compute sum(advance), sum(price)
- .in -5n
- .ED
- the \f2column\f1 for ``sum(price)'' still has a value of 1 and not 2,
- because the ``title_id'' column in the \f2select-list\f1
- is not a compute column and therefore is ignored when determining the compute column's number.
- .in -.375i
- .Re
- .br
- A BYTE pointer to the data for a
- particular column in a particular compute.
- Be sure to cast this pointer into the proper type.
- A BYTE pointer to NULL is returned if there is no such column or compute
- or if the data has a null value.
- .sp
- \*L allocates and frees the data space that the BYTE pointer points to.
- Do not overwrite this space.
- .Sa
- dbadlen,
- dbaltbind,
- dbaltlen,
- dbalttype,
- dbgetrow,
- dbnextrow,
- dbnumalts
-