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!

How to loop through columns of a table?

763890May 10 2010 — edited May 10 2010
Hi, guys

Is there a way to loop through each column of a table? If there is a way, then how?

I have a table with columns of different datatypes , and I want to set default values for each column with a loop but don't know how to make it happen.

For example,

Table: Employees
declare
  rec  Employees%ROWTYPE;
begin
  for col in rec.empno .. rec.location loop
     if col = rec.empno then -- set default value for column empno;
     ...
  end loop;
end;
.
/
Sorry, I am a newbie to PL/SQL. Please help!
Thanks in advance.

Edited by: HappyJay on 2010/05/11 10:36
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 7 2010
Added on May 10 2010
4 comments
12,539 views