How to update or sort data in collection?
558902Nov 21 2007 — edited Jan 27 2008Hi all.
Below is my way to create a struct and collection
Step 1: created an object type.
CREATE TYPE department_type AS OBJECT (
DNO NUMBER (10),
NAME VARCHAR2 (50),
LOCATION VARCHAR2 (50)
);
Step 2: created a varray of the above type.
CREATE TYPE dept_array AS TABLE OF department_type;
Step 3: map this collection to an array in JAVA, and pass a collection into stored procedure.
Step 4: Cycle the data in that array
PROCEDURE insert_object (d dept_array)
AS
BEGIN
FOR i IN d.FIRST..d.LAST
LOOP
INSERT INTO department_teststruct
VALUES (d(i).dno,d(i).name,d(i).location);
END LOOP;
END insert_object;
My question is how can I update the item in that array. Can I use this way?
PROCEDURE insert_object (d dept_array)
AS
BEGIN
FOR i IN d.FIRST..d.LAST
LOOP
d(i).dno := '123';
INSERT INTO department_teststruct
VALUES (d(i).dno,d(i).name,d(i).location);
END LOOP;
END insert_object;
Best regards,
Andreas
Message was edited by:
Andreas Zhang