home *** CD-ROM | disk | FTP | other *** search
-
- 1 Version 4.0 -- 5/1/89 dbadlen
- ______________________________________________________________________
-
- NAME: dbadlen
-
- FUNCTION:
- Return the actual length of the data for a compute column.
-
- SYNTAX:
- DBINT dbadlen(dbproc, computeid, column)
-
- DBPROCESS *dbproc;
- int computeid;
- int column;
-
-
-
-
-
-
-
-
- dbadlen Version 4.0 -- 5/1/89 2
- ______________________________________________________________________
-
- COMMENTS:
-
- o This routine returns the actual length of the data for a par-
- ticular compute column.
- o Use the dbaltlen() routine to determine the maximum possible
- length for the data. Use dbadata() to get a pointer to the
- data.
-
- o Here's a program fragment that illustrates the use of
- dbadlen():
-
- DBPROCESS *dbproc;
- char biggest_name[MAXNAME+1];
- int namelen;
- int rowinfo;
-
- /* put the command into the command buffer */
-
-
- 3 Version 4.0 -- 5/1/89 dbadlen
- ______________________________________________________________________
- dbcmd(dbproc, "select name from sysobjects");
- dbcmd(dbproc, " order by name");
- dbcmd(dbproc, " compute max(name)");
-
- /* send the command to SQL Server and start execution */
- dbsqlexec(dbproc);
-
- /* process the command */
- dbresults(dbproc);
-
- /* examine each row returned by the command */
- while ((rowinfo = dbnextrow(dbproc)) != NO_MORE_ROWS)
- {
- if (rowinfo == REG_ROW)
- printf("regular row returned.\n");
- else
- {
-
-
-
- dbadlen Version 4.0 -- 5/1/89 4
- ______________________________________________________________________
- /* This row is the result of a COMPUTE clause,
- * and "rowinfo" is the computeid of this COMPUTE
- * clause.
- */
-
- namelen = dbadlen(dbproc, rowinfo, 1);
- strncpy
- (biggest_name,
- (char *)dbadata(dbproc, rowinfo, 1),
- namelen);
-
- /* Data pointed to by dbadata() is not
- * null-terminated.
- */
- biggest_name[namelen] = '\0';
-
- printf("biggest name = %s\n", biggest_name);
-
-
-
- 5 Version 4.0 -- 5/1/89 dbadlen
- ______________________________________________________________________
- }
- }
-
-
- PARAMETERS:
- dbproc - A pointer to the DBPROCESS structure that provides the
- connection for a particular front-end/SQL Server process. It
- contains all the information that DB-Library uses to manage
- communications and data between the front end and SQL Server.
- 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
- computeid corresponding to the first COMPUTE clause in a
- SELECT is 1. The computeid is returned by dbnextrow() or
- dbgetrow().
- column - The number of the column of interest. The first column
- is number 1.
-
-
-
- dbadlen Version 4.0 -- 5/1/89 6
- ______________________________________________________________________
-
- RETURNS:
- The length, in bytes, of the data for a particular compute
- column. If there is no such column or COMPUTE clause, dbadlen()
- returns -1. If the data has a null value, dbadlen() returns 0.
-
- SEE ALSO:
- dbadata, dbaltlen, dbalttype, dbgetrow, dbnextrow, dbnumalts
-
-
-
-
-
-
-
-
-
-
-
-