Home » SQL & PL/SQL » SQL & PL/SQL » How to display output of pl/sql table?
How to display output of pl/sql table? [message #254256] Thu, 26 July 2007 05:33 Go to next message
donind
Messages: 95
Registered: February 2007
Member
How to display output of pl/sql table?
Its throwing an error when i tried to execute this proc?

create or replace procedure bin_id1 is
num number:=0;
TYPE emp_rec IS RECORD
(eid emp.empno%TYPE,
jid emp.job%TYPE,
enam emp.ename%TYPE);
Type emp_rec_tab IS TABLE OF emp_rec
INDEX BY BINARY_INTEGER;
my_emp_rec emp_rec;
my_emp_rec_tab emp_rec_tab;


begin
num:=1;
select count(*) into num from emp;
for i in (select empno, ename, job from emp)
loop
my_emp_rec_tab(num):=i;
num:=num+1;
end loop;


for j in my_emp_rec_tab.first..my_emp_rec_tab.last
loop
dbms_output.put_line(my_emp_rec_tab(j).empno|| ' '||my_emp_rec_tab(j).ename|| ' '||my_emp_rec_tab(j).job);
end loop;
end;

Any help really thanks
Re: How to display output of pl/sql table? [message #254259 is a reply to message #254256] Thu, 26 July 2007 05:45 Go to previous messageGo to next message
flyboy
Messages: 1832
Registered: November 2006
Senior Member
Quote:
Its throwing an error when i tried to execute this proc?
Are you asking whether your code throws error? You should know it. But I do not see any error message in your post.

Read How to get a quick answer to your question: TIPS AND TRICKS and How to format your posts and adjust your post accordingly.

From the first glance, you did not initialize the collection. Check PL/SQl User's Guide and Reference, hint: EXTEND Method.
Re: How to display output of pl/sql table? [message #254263 is a reply to message #254259] Thu, 26 July 2007 05:54 Go to previous messageGo to next message
donind
Messages: 95
Registered: February 2007
Member


Here is the error message.

Wrong number or types of arguments in call to 'PUT_LINE'

Thanks in advance
Re: How to display output of pl/sql table? [message #254307 is a reply to message #254256] Thu, 26 July 2007 07:00 Go to previous message
S.Rajaram
Messages: 1027
Registered: October 2006
Location: United Kingdom
Senior Member
i don't think this procedure will be created sucessfully. Change the dbms_output.put_line as
dbms_output.put_line(my_emp_rec_tab(j).eid|| ' '||my_emp_rec_tab(j).enam|| ' '||my_emp_rec_tab(j).jid)

It should work.

cheers
Previous Topic: HOW TO GET FIRST DATE OF ENTERED DATE
Next Topic: Oracle 7.3 PL/SQL
Goto Forum:
  


Current Time: Mon Dec 05 08:43:29 CST 2016

Total time taken to generate the page: 0.04510 seconds