Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Insert into a table with while loop

roymakaaySep 10 2011 — edited Sep 12 2011
Hi
I have a table emp as the following:-
SQL> desc emp
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------

 EMPLOYEE_ID                                        NUMBER(6)
 
 SALARY                                             NUMBER(8,2)
 
 STARS                                              VARCHAR2(50)
I want to create a PL/SQL block that inserts an asterisk in the stars coulmn for every
employee's salary that more than $1,000 .
So I have written this code
SQL> declare
  2  sal emp.salary%type;
  3  begin
  4  while sal > 1000 loop
  5  insert into emp(stars) values('*');
  6  end loop;
  7  end ;
  8  /
PL/SQL procedure successfully completed.

But no asterisk entered
SQL> select * from emp where stars is not null;

no rows selected
Any help please.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 10 2011
Added on Sep 10 2011
18 comments
2,068 views