I get this error when I call the procedure ‘archive_things’ which in turns gives the error at INSERT INTO deleted_part_things
(id, part_id, file_name, file_type, thing, editable)
what does this mean?
PROCEDURE archive_things ( p_part_id IN NUMBER )
IS
thing_list bean_list;
BEGIN
thing_list := get_thingss_info(p_part_id);
insert_deleted_things(thing_list);
END archive_things;
FUNCTION get_things_info ( p_part_id IN NUMBER)
RETURN bean_list
IS
attachment_list bean_list;
BEGIN
SELECT file_thing_bean (id, hot_part_id, file_name, file_type, thing, editable)
BULK COLLECT INTO thing_list
FROM part_things
WHERE part_id =hot_part_id;
RETURN thing_list;
END get_things_info;
PROCEDURE insert_deleted_things( p_bean_list IN bean_list )
IS BEGIN
FORALL x IN INDICES OF p_bean_list
INSERT INTO deleted_part_things
(id, part_id, file_name, file_type, thing, auditable) <<<<< ERROR HERE!!!!!
VALUES
( p_bean_list(x).id, p_bean_list(x).parent_id, p_bean_list(x).file_name, p_bean_list(x).file_type,
p_bean_list(x).thing, p_bean_list(x).editable
);
END insert_deleted_things;
Two points:
PLS-00436is a restriction prior to 11G whereby you’re not able to reference columns in arowtypein aforall. There are a few ways round it:One, as Ollie suggested is to have the same number of columns in your table as in your
bulk collect. This isn’t always possible.Tom Kyte suggests set operations. The restriction on this is the size of the
bulk collectyou’re doing. If it’s bigger than the amount of undo you’re going to have problems. Also if you want to do something else with the data then you have to do that separately.The last option ( that I know of I’m sure there are more ) is to collect your records into individual
typesrather than arowtypeas per the following. The downside of this is that it may not be as quick as Tom’s method and it’s by no mean as clear as Ollie’s.I’ve just noted Sathya’s method, which would also work but requires a lot of SQL to be executed.