p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Database > Oracle
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Oracle General Oracle database discussions.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 8th, 2005, 07:09 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default PL/SQL Cursor help

Hello guys,
Can't figure what's the problem, I am trying to fetch the records that I created in a previous table by this code. This is actually cursor help that i need...

SET SERVEROUTPUT ON
set verify off

DECLARE
TYPE dept_tabtype IS TABLE OF dept%ROWTYPE INDEX BY BINARY_INTEGER;
dept_table dept_tabtype;
dept_rec dept%ROWTYPE;
CURSOR cur IS SELECT * from dept;
idx binary_integer;
BEGIN
open cur;
fetch cur bulk collect into dept_table;
close cur;

DBMS_OUTPUT.PUT_LINE('ID: (DEPTNO, DEPTNAME, LOC)');
DBMS_OUTPUT.PUT_LINE('---------------------------');
idx := dept_table.FIRST();
WHILE idx IS NOT NULL LOOP
dept_rec := dept_table(idx);
DBMS_OUTPUT.PUT_LINE(idx || ': (' || dept_rec.deptno || ',' || dept_rec.dname || ',' || dept_rec.loc || ')');
idx := dept_table.NEXT(idx);
END LOOP;
END;

it gives me this error

SQL> @prog5b.sql
fetch cur bulk collect into dept_table;
*
ERROR at line 9:
ORA-06550: line 9, column 33:
PLS-00597: expression 'DEPT_TABLE' in the INTO list is of wrong type
ORA-06550: line 9, column 5:
PL/SQL: SQL Statement ignored


any idea please need help thanks


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old March 12th, 2005, 01:19 AM
Authorized User
Points: 38, Level: 1
Points: 38, Level: 1 Points: 38, Level: 1 Points: 38, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2004
Location: , , India.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

DECLARE
v_deptno dbms_sql.Number_Table;
v_dname dbms_sql.Varchar2_Table;
v_loc dbms_sql.Varchar2_Table;
BEGIN
select deptno, dname, loc bulk collect into v_deptno, v_dname, v_loc from dept;
DBMS_OUTPUT.PUT_LINE('ID: (DEPTNO, DEPTNAME, LOC)');
DBMS_OUTPUT.PUT_LINE('---------------------------');
for i in 1..v_deptno.last loop
DBMS_OUTPUT.PUT_LINE(i || ': (' || v_deptno(i) || ',' || v_dname(i) || ',' || v_loc(i) || ')');
END LOOP;
END;
/


Sujit Ku. Mahapatra
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PL/SQL Somesh ASP.NET 1.0 and 1.1 Basics 7 December 15th, 2006 05:49 PM
Use returned cursor in another PL/SQL proc robertogalbiati Oracle 0 January 5th, 2006 12:19 PM
PL/SQL cooldude87801 Oracle 1 March 3rd, 2005 10:54 AM
PL/SQL i need help loveboy23 Oracle 3 January 6th, 2005 01:14 AM
PL/SQL help carly_1 Oracle 1 October 19th, 2003 09:14 PM



All times are GMT -4. The time now is 03:11 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc