473,508 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Displaying records using %ROWTYPE

26 New Member
Hi Experts,

I want to display all the elements of a %ROWTYPE type.How can i achieve that.

I have written one sample code.

DECLARE
TYPE dept_info IS record dept%ROWTYPE;
temp_dept_info dept_info;
BEGIN
SELECT *
BULK COLLECT
INTO temp_dept_info
FROM DEPT;
FOR i IN 1 .. temp_dept_info.LAST LOOP
DBMS_OUTPUT.PUT_LINE(temp_dept_info(i));
END LOOP;
END;

But it is showing error.

Here i am trying to display values of each column of dept Table.

Please guide me how to do this?
Waiting for your quick response.

Thanks,
Dilip
Jun 15 '07 #1
2 23403
debasisdas
8,127 Recognized Expert Expert
try this sample code
-------------------------------------
Expand|Select|Wrap|Line Numbers
  1. declare
  2. type tt is table of emp%rowtype;
  3. aa tt;
  4. begin
  5. select * bulk collect into aa from emp;
  6. for i in aa.first .. aa.last loop
  7. dbms_output.put_line (aa(i).ename||'  '||aa(i).sal);
  8. end loop;
  9. end;
  10.  
Jun 15 '07 #2
dilippanda
26 New Member
Hi,

Thanks for the reply.

I am trying to fetch each element using your suggestion with out knowing the column names to make it dynamic.

I have written one code for this.

DECLARE
TYPE dept_info IS TABLE OF dept%ROWTYPE;
temp_dept_info dept_info;
TYPE tab_objects IS TABLE OF VARCHAR2(50);
temp_objects tab_objects;
BEGIN
SELECT column_name
BULK COLLECT
INTO temp_objects
FROM user_tab_columns
WHERE table_name='DEPT';

SELECT *
BULK COLLECT
INTO temp_dept_info
FROM DEPT;

FOR i IN 1 .. temp_dept_info.LAST LOOP
DBMS_OUTPUT.PUT_LINE(temp_dept_info(i).temp_object s(1)||temp_dept_info(i).temp_objects(2)||temp_dept _info(i).temp_objects(3));
END LOOP;

END;

But it is throwing me the error:
ORA-06550: line 25, column 44:
PLS-00302: component 'TEMP_OBJECTS' must be declared
ORA-06550: line 25, column 5:
PL/SQL: Statement ignored

Please help me.

Thanks,
Dilip

try this sample code
-------------------------------------
Expand|Select|Wrap|Line Numbers
  1. declare
  2. type tt is table of emp%rowtype;
  3. aa tt;
  4. begin
  5. select * bulk collect into aa from emp;
  6. for i in aa.first .. aa.last loop
  7. dbms_output.put_line (aa(i).ename||'  '||aa(i).sal);
  8. end loop;
  9. end;
  10.  
Jun 15 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
4058
by: Matt K. | last post by:
Hi there, I have a form in an Access project that contains a subform which displays the results of a query of the style "select * from where = #a certain date#". In the main part of the form...
3
4645
by: Lyn | last post by:
I need some guidance for a technique that will allow me to accomplish the following... I have a table in which each record contains a photograph. I would like to display in a form a thumbnail...
2
2934
by: VM | last post by:
When I display data to a Windows datagrid I usually fill the underlying table (in another class) and then, once it contains all the data, I attach it to the grid. But there are some processes that...
14
5761
by: Karl O. Pinc | last post by:
Hi, Thought perhaps some other eyes than mine can tell if I'm doing something wrong here or if there's a bug somewhere. I've never passed a ROWTYPE varaible to a function but I don't see where...
3
2195
by: Richard Carpenter | last post by:
I understand how to use a dropdown list control to display the associated description value for a foreign key in a parent rather than the key itself, but I don't like having to disable the control...
10
3232
by: minapatel | last post by:
Hi, I am trying to purge cases using an sql cursor:- cursor all_cases is cursor all_cases is select c.id00_warehouse, c.id00_case_nbr, c.id00_status_flag, c.id00_dlm from phpick00...
1
1380
by: sushant2009 | last post by:
Hi , I want to display empty databae table(actually table contains lot of records) to datagrid using dataset and dataadpter. After displaying i will fill new records in datagrid and i will save...
0
1452
by: John Kirkpatrick | last post by:
Hi all, I am having difficulty displaying records on a frontend MS Access 2000 form using a MySQL backend. The following code works well with the Jet database engine but doesn't work properly...
5
1938
by: sejal17 | last post by:
hello everyone, I have a problem with displaying records between two dates.Below is my designing page: start date: combobox of month(smonth) & combobox of year(syear) end date :...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7118
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7323
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.