|
|
 |
| 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.
|
 |

March 8th, 2005, 07:09 AM
|
|
Registered User
|
|
Join Date: Mar 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

March 12th, 2005, 01:19 AM
|
|
Authorized User
|
|
Join Date: Dec 2004
Location: , , India.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |