Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: PL/SQL Questions.

Re: PL/SQL Questions.

From: Anthony Scott <ascott_at_interaccess.com>
Date: Sun, 29 Jul 2001 12:27:51 -0500
Message-ID: <3B644797.36C099FD@interaccess.com>

Jim Kennedy wrote:

> It works perfectly. What you are doing is:
> x=1
> set testid=1 for ALL rows in the users table
> print out x (which is 1)
> x=2
> set testid=2 for ALL rows in the users table
> print out x (which is 2)
> x=3
> set testid=3 for ALL rows in the users table
> print out x (which is 3)
> So now ALL the rows in the user table for testid are = to 3.
> So
> Select testid from users returns
> 3
> 3
> 3
> which is correct.
>
> I think what you are trying to do is set testid to 1 in the "first" row, 2
> in the "second" row and 3 in the "third" row.
> To do that just do:
>
> update users set testid=rownum;
> Jim
>
> "Anthony Scott" <ascott_at_interaccess.com> wrote in message
> news:3B643DB5.E34DD940_at_interaccess.com...
> > Can anyone tell me why the following code doesn't produce the desire
> > results?
> >
> >
> > BEGIN
> > FOR x IN 1..3 LOOP
> > update users set testid = x;
> > DBMS_OUTPUT.PUT_LINE(x);
> > END LOOP;
> > END;
> >
> > output to sqlplus is : 1
> > 2
> > 3
> >
> > output in testid is : 3
> > 3
> > 3
> >
> >
> >
> > RH 6.1
> > Oracle 8.1.6
> >
> > Tony
> >

Thank you

Anthony Scott Received on Sun Jul 29 2001 - 12:27:51 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US