Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

oracle RowType Issue

 
   Database Help (Home) -> Programming RSS
Next:  Is AskTom Down...Again?  
Author Message
FB

External


Since: Jan 20, 2010
Posts: 1



(Msg. 1) Posted: Wed Jan 20, 2010 7:11 am
Post subject: oracle RowType Issue
Archived from groups: microsoft>public>sqlserver>programming (more info?)

Hi All,
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 :


declare
empRowType Emp%ROWTYPE;
begin
SELECT * INTO empRowType FROM Emp
WHERE Emp_id = 101 ;


for x in ( select column_name from user_tab_columns where
table_name = 'Emp')
loop
i:=i+1;
y:= x.column_name;
z:= 'empRowType.'|| x.column_name;
dbms_output.put_line (z);
end loop;
end


Steps :


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
the
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.'||
x.column_name;)
5) Print the Value


I get a O/P as String as :


empRowType.Emp_ID
empRowType.Emp_Name
empRowType.Emp_Department


but i want the O/P as


"101"
"John Peter"
"Marketing Department"


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,


FB

 >> Stay informed about: oracle RowType Issue 
Back to top
Login to vote
Plamen Ratchev

External


Since: Aug 20, 2008
Posts: 672



(Msg. 2) Posted: Wed Jan 20, 2010 10:19 am
Post subject: Re: oracle RowType Issue [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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.

--
Plamen Ratchev
http://www.SQLStudio.com

 >> Stay informed about: oracle RowType Issue 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
%Rowtype in SQL server - Hi, I'm in the process of converting an oracle stored procedure into Sql server 2005. Please let me know if there is any alternative in SQL server 2005 for %Rowtype while working with cursors. Thanks in advance Chandra.

UPDATETEXT issue - Hi, I haven't really figured out how to work with UPDATETEXT. What I would like to do is concatenated string and have to added to a text datatype. UPDATE tbl SET textdata = textdate + string WHERE... So with UPDATETEXT how can I be sure that the string...

OPENROWSET issue - I have an issue with openrowset: I'm trying to access data through the EXOLEDB provider with OPENROWSET, but I get a cannot create new session on OLEDB provider error IDBCreateSession::CreateSession 0x80040e19. (authentication definately suceeds..

xp_sendmail issue - Hello, I have SQL 2000 with service pack 3a: When I use xp_sendmail with a file attached, it doesn't save to the specified file system folder, SQL 7 does. Here is the query: set quoted_identifier off Declare @StringMonth varchar(5) ,..

join issue - Hi All, There are two tables. first is stock list table (STOCK_LIST), second for dailly rate for currencies(DAILY_CURRENCY_RATES). in the STOCK_LIST table there are two columns, one for price(PRICE_1) and one for currency id(CURRENCY_ID). ..
   Database Help (Home) -> Programming All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]