Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > Oracle
Password Reminder
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 Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 8th, 2005, 07:09 AM
Registered User
 
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


  #2 (permalink)  
Old March 12th, 2005, 01:19 AM
Authorized User
 
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
 


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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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 08:14 PM



All times are GMT -4. The time now is 02:39 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.