loop-over-results

$Revision: 1.1.2.2 $

Macro

Package: DBI

Arguments: ((&key types column-names do-column-names return hstmt width) &rest body)

After executing a sql statement with rr-sql, this form loops once for each result row, evaluating the body. types specifies how the values for each column should be returned (as it does for sql, see below for possible values of types). If you wish to have a list of the result column names computed, then pass a symbol as the value of column-names and pass a true value for do-column-names. If this is done then the symbol that is the value of column-names will be bound to the list of column names before the first time that body is evaluated. After body is evaluated for the last time the expression return is evaluated and the value of it is the value of the loop-over-results form. The statement handle of the results that are being scanned by this form is hstmt.

Within the body there are two macros defined: column-count and column-value. The macro column-count takes no arguments and its value is the number of columns of results available. The column-value macro takes one argument, the column number, and returns the value in that column for the current row. Note: column numbers are one-based, thus the value passed to column-value should be between 1 and the number of columns returned. The type of value returned by column-value will be a string unless some other type of value is specified in the types argument.

width is the size for character buffers used in retrieving character-valued fields. If not given, then the width for the database, db-width, is used.

Possible values for types: normally the column values in each row are returned a strings (or nil for the null value). You can specify in types the kinds of values you want returned for each column. types is a list of type specifiers from this table

Specifier Meaning
:int return as a 4 byte signed value
:long return as a 4 byte signed value
:double return as an 8 byte floating point value
t return as a string (the default)
:auto return the best Lisp type for the given database type. In 5.0.1, only integers and floating-point numbers are converted. All other types are returned as strings, as with the t specifier.

This symbol is associated with the Allegro CL ODBC (AODBC) interface, version 2. Version 2 is new in Allegro CL 5.0.1. It is incompatible with the earlier version 1. Not all customers will have Allegro ODBC version 2. Contact your Franz Inc. sales representative for more information.

Allegro ODBC version 2 is described in aodbc_v2.htm.

The general documentation description is in introduction.htm. The index in index.htm.

Copyright (C) 1998-1999, Franz Inc., Berkeley, CA. All Rights Reserved.