CREATE OR REPLACE TYPE NEW_ADDRS_OBJ
AS OBJECT (newAddress1 varchar2(20),
newAddress2 varchar2(20),
city varchar2(20),
state varchar2(20),
zip number(20))
create or replace type NEW_ADDRS_OBJ_ARRAY as table of NEW_ADDRS_OBJ
CREATE OR REPLACE TYPE ACCOUNT_OBJ
AS OBJECT (fname varchar2(20),
newAddress NEW_ADDRS_OBJ_ARRAY)
create or replace type ACCOUNT_OBJ_ARRAY as table of ACCOUNT_OBJ
Now when calling the procedure
CREATE OR REPLACE PROCEDURE INSERT_NEW_ADDRESS ( account_array in ACCOUNT_OBJ_ARRAY ) AS
tempaddres NEW_ADDRS_OBJ_ARRAY;
begin
for i in 1..account_array.count loop
tempaddres := NEW_ADDRS_OBJ_ARRAY();
tempaddres := account_array(i).newAddress;
for j in 1..tempaddres.count loop
insert into TEST_ACCOUNT (ACCOUNT,NEWADDRESS1 ,NEWADDRESS2 ,CITY ,STATE ,ZIP )
values(account_array(i).fname,
tempaddres(j).newAddress1,
tempaddres(j).newAddress2,
tempaddres(j).city,
tempaddres(j).state,
tempaddres(j).zip);
end loop;
end loop;
end;
i can make use of arraydescriptor to pass parent array ACCOUNT_OBJ_ARRAY ,but how to pass array inside it (the array of new address objects) from Spring procedure call?
See the SO question “How to call oracle stored procedure which include user-defined type in java?” for an example of how to bind a SQL nested table of SQL object in java. Here the SQL object also itself contains a nested table of object. The method is similar (SQL arrays are bound by ARRAY Object in java, SQL objects are bound by STRUCT).
I will show a demo using the Oracle java jvm:
Now we call the java procedure: