Re: Explicit Cursor and Insert Into table question



General Fear wrote:
I am using 10g.

I am running a test. I want to create an explicit cursor. Then I want
to put the data that is in the cursor into a table. The problem is
that the table has a lot of fields. I could put the data into
variables then use the insert into command.

Is there an better way to use explicit cursors and put that data into
a table? I tried searching the net but the examples did not help.

No Oracle version.
No DDL.
No DML.
And the explanation is far from clear.
What about the following doesn't do what you are asking?

DECLARE
CURSOR c IS
SELECT * FROM all_tables;
BEGIN
FOR r IN c LOOP
INSERT INTO t
(table_name)
VALUES
(r.table_name);
END LOOP;
COMMIT;
END;
/

That said from your explanation of what you are trying to do
an explicit cursor, and procedural code, is abou the least
efficient way to solve the problem. Far better would be:

INSERT INTO t SELECT table_name FROM all_tables;
COMMIT;
--
Daniel A. Morgan
Oracle Ace Director & Instructor
University of Washington
damorgan@xxxxxxxxxxxxxxxx (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
.