Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Oracle Magazine Blooper
"Niall Litchfield" <niall.litchfield_at_dial.pipex.com> wrote in message news:<409f17d0$0$25329$cc9e4d1f_at_news-text.dial.pipex.com>...
> "Daniel Morgan" <damorgan_at_x.washington.edu> wrote in message
> news:1084113115.36012_at_yasure...
> > Serge Rielau wrote:
> >
> > > In defense of examples it always depends on what you want to show.
> > > I for one find it very hard to find examples that show consicely how a
> > > given feature works and at the same time make sense and are good style.
> > > E.g. a good way to explain a WHILE loop is to code a SUM or COUNT, but
> > > who in his right mind would do that proceduraly?
> > >
> > > Cheers
> > > Serge
> > >
> >
> > The demo I use is:
> >
> > DECLARE
> >
> > i PLS_INTEGER := 999;
> >
> > BEGIN
> > WHILE i < 1100
> > LOOP
> > i := i + 1;
> > INSERT INTO loop_test VALUES (i);
> > END LOOP;
> > COMMIT;
> > END;
> > /
> >
> > I think it makes the point.
>
> But as with Serge's point, I don't think I'd do that either. I'd write
>
> BEGIN
> for i in 1..1100 loop
> insert into loop_test values(i);
> end loop;
> end;
> /
>
> for the demo or perhaps even better
>
> insert into loop_test
> select rownum from all_objects where rownum <= 1100;
> commit;
>
> :(
No that's not better. It uses the dreaded ROWNUM! IMHO, ROWNUM is an abomination, unfit for use in any relational DBMS.
Can you tell I do not like ROWNUM? Why? It gets beginners thinking there is some order to rows in a table when there really isn't.
Enjoy,
Ed
Received on Tue May 11 2004 - 12:35:56 CDT
![]() |
![]() |