Extending the LOOP macro
"R. Mattes" <rm-OuoMP45H64u6ogTlOYt/[email protected]> Mon, 17 Oct 2005 16:20:58 +0200
| Newsgroups | gmane.lisp.clsql.devel |
|---|---|
| Message-ID | <[email protected]> |
I was just playing arround with clsql's extended loop macro
and realized that the extension basically performs a 'select'
and collects the result into a temporary result set and then iterates
over it. Hmmm. I somehow expected such an iteration to expand into
an equivalent sql _cursor_ operation. i.e. something like the following
pseudo-code:
Loop init:
(optional) BEGIN TRANSACTION
DECLARE a cursor for the given select statement
OPEN the cursor
Loop body:
FETCH next row from cursor and bind it to the
loop variables.
Loop termination:
CLOSE cursor
(optional) end transaction.
This does make a difference in performance when the loop contains
WHILE/REPEAT or RETURN clauses since the current version fetches
all results before evaluating and conditions.
Are there any plans of supporting cursors in clsql (maybe with a
new keyword '... being a cursor for ...' or even '... being
a readonly cursor for ...')? I'd tackle the problem myself but i
have never before extended CL's loop syntax and can't even find good
documentation for that task.
Cheers Ralf Mattes