|
 |
Gail Shaw wrote:
> To quote a friend on SQL central. Cursors are RBAR (Row by agonising row)
> processing
I see. I think...
> SQL's a set-based language. It's supposed to process datasets, not
> individual rows.
Agreed.
> Here's a cursor syntax in T-SQL. My oracle's way too rusty
> for me to attempt to do the same in pl-sql.
I probably wouldn't recognise it if you did. *I* haven't done PL/SQL in
ages either...
> DECLARE curSomething CURSOR FOR
> SELECT somecolumn FROM SomeTable
>
> FETCH NEXT FROM curSomething INTO @AVariable
>
> WHILE @@FETCH_STATUS = 0 -- there are rows in the cursor
> BEGIN
> -- Do something with the variable @AVariable
> FETCH NEXT FROM curSomething INTO @AVariable
> END
Right. So is it that cursors are inherantly evil? Or just that people
tend to misuse them to do row-based processing when they could and
should do set-based?
I was under the vague impression that a cursor is a thing that allows
you to, say, show 1 page of results, and then fetch the next page a bit
later...
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
 |