从 Spring DAO 调用 Sql 过程
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
现在,当调用该过程时,
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;
我可以利用 arraydescriptor 来传递父数组 ACCOUNT_OBJ_ARRAY ,但是如何从 Spring 过程调用传递其中的数组(新地址对象的数组)?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅SO问题“如何在java中调用包含用户定义类型的oracle存储过程?"查看如何在java中绑定SQL对象的SQL嵌套表的示例。这里的 SQL 对象本身也包含一个对象的嵌套表。方法类似(java中SQL数组通过ARRAY对象绑定,SQL对象通过STRUCT绑定)。
我将展示一个使用 Oracle java jvm 的演示:
现在我们调用 java 过程:
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: