Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

PL/SQL insert nested table value into another nested table.

930602Jun 6 2012 — edited Jun 7 2012
Hi Guy

I've created a table with nested table in and inserted some values. note: this is just an example the real table has more values inserted.

REATE OR REPLACE TYPE tt_hours AS OBJECT(hours INTEGER, data NUMBER);
/
CREATE OR REPLACE TYPE tt_day AS VARRAY(7) OF tt_hours;
/
CREATE TABLE old_table
(
DAY DATE,
VALUE_hours tt_day
);
INSERT INTO old_table
(day, value_hours)
VALUES
(TO_DATE('01/06/2012 22:00:34'),
tt_DAY(
tt_hours(1,0.025727),
tt_hours(2,0.012047),
tt_hours(3,0.012857),
tt_hours(4,0.012107),
tt_hours(5,0.012849),
tt_hours(6,0.01215),
tt_hours(7,0.0129)))

I've also created another table with same structure but with no value inserted.

REATE OR REPLACE TYPE yy_hours AS OBJECT(thours INTEGER, tdata NUMBER);

CREATE OR REPLACE TYPE yy_day AS VARRAY(7) OF yy_hours;

CREATE TABLE new_table ( tDAY DATE, VALUE_thours yy_day )

I run a select from statement which workout the average of data from old table by group.

SELECT to_char(DAY, 'Day'), hours, AVG(data)
FROM old_table n, TABLE(n.value_hours) v
GROUP BY to_char(DAY, 'Day'), hours;

How do I insert the result in new_table's ?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 5 2012
Added on Jun 6 2012
7 comments
1,082 views