Re: Learning Cursors



Jim Kennedy ha escrito:

"PHernandez" <phph109@xxxxxxxx> wrote in message
news:1140705075.095896.244040@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Mark D Powell ha escrito:

Every SQL statement is a cursor. I take you are really talking about
explicit cursors and cursor for loops.

A cursor may be necessary when you need to process each row in a result
set individually in your logic. Generally speaking the logic needs to
be complex and not easily solved within a single query. Otherwise you
should code the single query. The presence of bad data or error
conditions that need to be dealt with on an individual basis while the
remander of the data is processes might be a reason to use a cursor.

I have a follow up question on this, if I have a query that returns > 1
row and I'd want to display the result in a gui of some sort, e.g. a
web-page- I'm pretty much stuck with a cursor, right? Or are there
other ways to do it?

--ph

Oracle 10g

Yes, how else would you get the information?

Hey, that's my question!!

To extend it a little. Many times all I do with a cursor is to loop the
result and more or less concatenate the rows to a string. e.g:
"<person><name>Patrick</name><lname>Green</lname></person><person> ....
"

Since it's kind of a trivial task and no doubt very common, I thought
that Oracle maybe provide some kind of magic to do it without looping a
cursor.

--ph

.



Relevant Pages

  • Re: Why are cursors Bad in Sql 2000
    ... SELECT MyColumn1 FROM MyTable ... These articles are also suggesting I use While loops> instead of cursors. ... First, I created a stored proc which> uses a temp table and a cursor on 10,000 rows. ...
    (microsoft.public.sqlserver.programming)
  • Re: Why are cursors Bad in Sql 2000
    ... sets are going to be faster than the various 'cursor' solutions. ... These articles are also suggesting I use While loops ... > uses a temp table and a cursor on 10,000 rows. ...
    (microsoft.public.sqlserver.programming)
  • Re: stored procedure timeout 18:12:26
    ... The outer stored procedure that loops uses a cursor: ... The timeout period elapsed prior to completion of the ... The cursor loops on 9741 rows and each row is used to execute several inner ...
    (microsoft.public.sqlserver.server)
  • Re: Cursor for loops
    ... No, no, I didn't mean simply 'for loops', but 'cursor for loops'. ... They look like this in Oracle: ... FOR mycursor IN ...
    (microsoft.public.sqlserver.server)
  • Re: Cursor for loops
    ... No, no, I didn't mean simply 'for loops', but 'cursor for loops'. ... They look like this in Oracle: ... FOR mycursor IN ...
    (microsoft.public.sqlserver.programming)