From: FB on 20 Jan 2010 10:11
Im new to Oracle.
I have a Rowtype and i want to Loop through that Rowtype without
mentioning the Column name.
My code as below :
SELECT * INTO empRowType FROM Emp
WHERE Emp_id = 101 ;
for x in ( select column_name from user_tab_columns where
table_name = 'Emp')
z:= 'empRowType.'|| x.column_name;
1) First Im declaring a RowType of Employee table.
2) Assigning value to RowType by making a select statement.
3) I want to get all the column name value printed so im selecting
column names of the table by using USER_TAB_COLUMNS table and running
a for loop.
4) Im concatenating RowTypeName.Column name (ex: z:= 'empRowType.'||
5) Print the Value
I get a O/P as String as :
but i want the O/P as
Pls someone help. This is a sample i have created to put in this
website. I cannot use RowType column to meet the requirement.
Thanks in advance,
From: Plamen Ratchev on 20 Jan 2010 10:19
It is best to post your question to Oracle related forum. This newsgroup is dedicated to SQL Server and even there are
folks around here with Oracle knowledge you can get better answer in Oracle dedicated forum.
Instead of doing a loop seems you can use unpivoting technique to get the results you need.