Re: ODBC: fetch-row and eof-value

Jack Tanner <[email protected]>
Newsgroups gmane.lisp.allegro
Message-ID <[email protected]>
Jack Tanner wrote:
> I'd like to loop over the results of an AODBC query object using
> dbi:fetch-row. Could someone give an example of the correct syntax for
> testing for "eof-value"?

Thanks to the kind person who responded to me off-list, the correct 
syntax is:

(let ((row (dbi:fetch-row <your query here> nil :the-end)))
    (if (eq row :the-end)
        (<no more rows; do sth accordingly>)
      (<do whatever you want with the row here>)))

Specifically, here's a tail-recursive function that works nicely:

(defun print-all-rows (query-obj)
   (let ((row (dbi:fetch-row query-obj nil :eof)))
     (cond ((eq row :eof)
	   (dbi:close-query query-obj))
	  (t
	   (print row)
	   (print-all-rows query-obj))
       )))

Regards,
JT
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.