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!

Assign a collection field name dynamically

1003788Apr 17 2013 — edited Apr 19 2013
Hi
I am new to this forum. Could you please help me out with this.

I have a main collection which has 20 columns. I need to pass each of this 20 columns in another function to validate some functionality. I am thinking of doing that in naother loop. I put all thsi 20 column names in another nested table collection. I will get the column_name form the second loop. Can I combine that with the first collection to get the value of that column_name.

I will give an example wit 2 loops.



DECLARE
V_NAME VARCHAR2(100);
V1 VARCHAR2(100);

begin
for i in (select * from employeeS)
loop

for j in(select 'DEPARTMENT_ID' COLUMN_NAME FROM DUAL)
LOOP
v_name:=j.COLUMN_NAME;


v1:=i.V_NAME;


-- I need to get the value of " i.department_id "in variable v1. I need to pass the value of i.department_id (like 20 columns) to another function.
--That is the need for second loop




DBMS_OUTPUT.PUT_LINE('V1'||V1);
END LOOP;
END LOOP;

END;


This code is not compiling. It would be great ,If you can assist me with this.

My oracle version is 11g. If you need any further information, I can provide that.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 17 2013
Added on Apr 17 2013
10 comments
789 views