Re: Cursor for loops

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Agoston Bejo (gusz1_at_freemail.hu)
Date: 10/12/04


Date: Tue, 12 Oct 2004 11:56:45 +0200

No, no, I didn't mean simply 'for loops', but 'cursor for loops'.
They look like this in Oracle:

FOR mycursor IN (SELECT PERSON_ID, NAME FROM T_PERSON)
LOOP
 doSomething(mycursor.PERSON_ID);
END LOOP;

I think this is a very useful construct, therefore I'm looking for something
similar in T-SQL.

"Ian Oldbury" <ian_oldbury@_NO_msn_SPAM_.com> wrote in message
news:Orj1$wDsEHA.2136@TK2MSFTNGP14.phx.gbl...
> i don't know Oracle however have a look at ....
>
> WHILE @i < 100
>
> BEGIN
>
> -- your task
>
> SET @i = @i + 1
>
> END
>
>
> i hope it helps
> ian
>
> "Agoston Bejo" <gusz1@freemail.hu> wrote in message
> news:Oy%23fjvDsEHA.516@TK2MSFTNGP09.phx.gbl...
> > Is there something in T-SQL that is the same as FOR loops in Oracle
> > PL/SQL?
> > if not, what is the closest equivalent?
> >
> >
> >
>
>



Relevant Pages

  • Re: hierarchical query - returning a treewalked subset
    ... pretty small), and if a row is LEVEL 1, it loops thru the resultset ... Take any query that produces a result set in Oracle. ... only for system account ... 100 torrent files; ...
    (comp.databases.oracle.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)
  • 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: an old worn interview question
    ... directed graph. ... easily loops can arise. ... This query will search a table for all the rows sharing a common ... then Oracle returns an error. ...
    (comp.programming)
  • Re: Learning Cursors
    ... explicit cursors and cursor for loops. ... A cursor may be necessary when you need to process each row in a result ... be complex and not easily solved within a single query. ... Oracle 10g ...
    (comp.databases.oracle.server)