Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > Oracle
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
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


 
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




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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.