SqlAData$

Returns the data in a COMPUTE clause column.

Syntax

SqlAData$ ( sqlconn%, computeid%, column% )

where

sqlconn%
Is a SQL Server connection. The value of sqlconn% is returned by SqlOpen%.
computeid%
Is the COMPUTE clause. A SELECT statement can have multiple COMPUTE clauses, which can have varying numbers of aggregate operators and aggregate targets. The computeid% is returned by SqlNextRow% or SqlGetRow%.
column%
Is the number of the column. The first column returned is number 1.

Returns

A string containing the data in the compute column. For the SQL Server datatypes binary, varbinary, and image, SqlAData$ returns a string of binary data. For all other datatypes, SqlAData$ returns a string of characters. When there is no such column or when the data is NULL, an empty string is returned. To make sure that the data really is NULL, always check for a return of 0 by using SqlADLen&.

Remarks

After each call to SqlNextRow% that returns a value greater than 0, use SqlAData$ to obtain the data in a particular COMPUTE clause column. The data is not null-terminated. Use SqlADLen& to get the length of the data in a COMPUTE clause column.

Example

'Put commands into the command buffer.
cmd$ = "SELECT db_name(dbid), dbid, size FROM sysusages"
cmd$ = cmd$  " ORDER BY dbid"
cmd$ = cmd$  " COMPUTE SUM(size) BY dbid"
Result% = SqlCmd%(Sqlconn%, cmd$)
'Send commands to SQL Server and start execution.
Result% = SqlExec%(Sqlconn%)
Result% = SqlResults%(Sqlconn%)
'Examine the results of the COMPUTE clause.
IF Result% = SUCCEED THEN
   DO UNTIL Result% = NOMOREROWS
      Result% = SqlNextRow%(Sqlconn%)
      IF Result% = NOMOREROWS THEN Exit DO
      IF Result = REGROW THEN
         PRINT "regular row returned."
         PRINT
      ELSE
         'This row is the result of a COMPUTE clause
         'and Result% is the computeid% of this 
         'COMPUTE clause
         sum = Val(SqlAData$(Sqlconn%, Result%, 1))
         PRINT "sum = "; sum
         PRINT
      END IF
   LOOP

See Also

SqlADLen&, SqlAltLen%, SqlAltType%, SqlGetRow%, SqlNextRow%, SqlNumAlts%